Seastar
High performance C++ framework for concurrent servers
|
Read side of a seastar::pipe.
The read side of a pipe, which allows only reading from the pipe. A pipe_reader object cannot be created separately, but only as part of a reader/writer pair through seastar::pipe.
#include <seastar/core/pipe.hh>
Public Member Functions | |
future< std::optional< T > > | read () |
Read next item from the pipe. More... | |
void | unread (T &&item) |
Return an item to the front of the pipe. More... | |
pipe_reader (pipe_reader &&other) noexcept | |
pipe_reader & | operator= (pipe_reader &&other) noexcept |
|
inline |
Read next item from the pipe.
Returns a future value, which is fulfilled when the pipe's buffer becomes non-empty, or the write side is closed. The value returned is an optional<T>, which is disengaged to mark and end of file (i.e., the write side was closed, and we've read everything it sent).
|
inline |
Return an item to the front of the pipe.
Pushes the given item to the front of the pipe, so it will be returned by the next read() call. The typical use case is to unread() the last item returned by read(). More generally, it is legal to unread() any item, not just one previously returned by read(), but note that the unread() is limited to just one item - two calls to unread() without an intervening call to read() will cause an exception.