summaryrefslogtreecommitdiffstats
path: root/yt/cpp/mapreduce/interface/abortable_stream.h
blob: 40316e1b790053ebb321b50edb45d75d030d6278 (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
24
25
26
27
28
29
30
31
32
33
#pragma once

#include <util/stream/input.h>

#include <exception>

namespace NYT {

////////////////////////////////////////////////////////////////////////////////

/// @brief Input stream that supports aborting the read operation.
///
/// Extends @ref IInputStream with the ability to immediately cancel current or future reads.
class IAbortableInputStream
    : public IInputStream
{
public:
    ~IAbortableInputStream() override = default;

    /// @brief Immediately abort the stream, cancelling current and future reads.
    ///
    /// Some clients have already implemented this interface, so using pure virtual method leads to build errors.
    virtual void Abort();

    /// @brief Check whether the stream has been aborted.
    virtual bool IsAborted() const;

    static bool IsAbortedError(const std::exception_ptr& error);
};

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT