1 | #pragma once |
2 | |
3 | #include <IO/WriteBufferFromFileDescriptor.h> |
4 | |
5 | |
6 | namespace DB |
7 | { |
8 | |
9 | /** Write to file descriptor but drop the data if write would block or fail. |
10 | * To use within signal handler. Motivating example: a signal handler invoked during execution of malloc |
11 | * should not block because some mutex (or even worse - a spinlock) may be held. |
12 | */ |
13 | class WriteBufferFromFileDescriptorDiscardOnFailure : public WriteBufferFromFileDescriptor |
14 | { |
15 | protected: |
16 | void nextImpl() override; |
17 | |
18 | public: |
19 | using WriteBufferFromFileDescriptor::WriteBufferFromFileDescriptor; |
20 | ~WriteBufferFromFileDescriptorDiscardOnFailure() override {} |
21 | }; |
22 | |
23 | } |
24 | |