aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/IO/WriteBufferFromFileDescriptorDiscardOnFailure.h
blob: 2803dd4e8bff93b4a1ede2a232c3377811b4af0a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#pragma once

#include <IO/WriteBufferFromFileDescriptor.h>


namespace DB
{

/** Write to file descriptor but drop the data if write would block or fail.
  * To use within signal handler. Motivating example: a signal handler invoked during execution of malloc
  *  should not block because some mutex (or even worse - a spinlock) may be held.
  */
class WriteBufferFromFileDescriptorDiscardOnFailure : public WriteBufferFromFileDescriptor
{
protected:
    void nextImpl() override;

public:
    using WriteBufferFromFileDescriptor::WriteBufferFromFileDescriptor;
    ~WriteBufferFromFileDescriptorDiscardOnFailure() override = default;
};

}