Seastar
High performance C++ framework for concurrent servers
Public Member Functions | List of all members
seastar::pipe_reader< T > Class Template Reference

Detailed Description

template<typename T>
class seastar::pipe_reader< T >

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< compat::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)
 
pipe_readeroperator= (pipe_reader &&other)
 

Member Function Documentation

◆ read()

template<typename T>
future<compat::optional<T> > seastar::pipe_reader< T >::read ( )
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).

◆ unread()

template<typename T>
void seastar::pipe_reader< T >::unread ( T &&  item)
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.


The documentation for this class was generated from the following file: