CAF  0.17.3
Public Types | Public Member Functions | Protected Member Functions | List of all members
caf::io::network::stream Class Reference

A stream capable of both reading and writing. More...

#include <stream.hpp>

Inheritance diagram for caf::io::network::stream:
caf::io::network::event_handler caf::io::network::stream_impl< ProtocolPolicy > caf::io::network::stream_impl< caf::policy::tcp >

Public Types

using manager_ptr = intrusive_ptr< stream_manager >
 A smart pointer to a stream manager.
 

Public Member Functions

 stream (default_multiplexer &backend_ref, native_socket sockfd)
 
void start (stream_manager *mgr)
 Starts reading data from the socket, forwarding incoming data to mgr.
 
void activate (stream_manager *mgr)
 Activates the stream.
 
void configure_read (receive_policy::config config)
 Configures how much data will be provided for the next consume callback. More...
 
void write (const void *buf, size_t num_bytes)
 Copies data to the write buffer. More...
 
byte_bufferwr_buf ()
 Returns the write buffer of this stream. More...
 
byte_bufferrd_buf ()
 Returns the read buffer of this stream. More...
 
void flush (const manager_ptr &mgr)
 Sends the content of the write buffer, calling the io_failure member function of mgr in case of an error. More...
 
void removed_from_loop (operation op) override
 Callback to signalize that this handler has been removed from the event loop for operations of type op.
 
void graceful_shutdown () override
 Shuts down communication on the managed socket, eventually removing this event handler from the I/O loop.
 
void force_empty_write (const manager_ptr &mgr)
 Forces this stream to subscribe to write events if no data is in the write buffer.
 
- Public Member Functions inherited from caf::io::network::event_handler
 event_handler (default_multiplexer &dm, native_socket sockfd)
 
virtual void handle_event (operation op)=0
 Returns true once the requested operation is done, i.e., to signalize the multiplexer to remove this handler. More...
 
native_socket fd () const
 Returns the native socket handle for this handler.
 
default_multiplexer & backend ()
 Returns the multiplexer this acceptor belongs to.
 
int eventbf () const
 Returns the bit field storing the subscribed events.
 
void eventbf (int value)
 Sets the bit field storing the subscribed events.
 
bool read_channel_closed () const
 Checks whether close_read_channel has been called.
 
void passivate ()
 Removes the file descriptor from the event loop of the parent.
 
bool ack_writes ()
 Returns whether this event handlers signals successful writes to its parent actor.
 
void ack_writes (bool x)
 Sets whether this event handlers signals successful writes to its parent actor.
 

Protected Member Functions

template<class Policy >
void handle_event_impl (io::network::operation op, Policy &policy)
 
- Protected Member Functions inherited from caf::io::network::event_handler
void activate ()
 Adds the file descriptor to the event loop of the parent.
 
void set_fd_flags ()
 Sets flags for asynchronous event handling on the socket handle.
 

Additional Inherited Members

- Protected Attributes inherited from caf::io::network::event_handler
native_socket fd_
 
state state_
 
int eventbf_
 
default_multiplexer & backend_
 

Detailed Description

A stream capable of both reading and writing.

The stream's input data is forwarded to its manager.

Member Function Documentation

◆ configure_read()

void caf::io::network::stream::configure_read ( receive_policy::config  config)

Configures how much data will be provided for the next consume callback.

Warning
Must not be called outside the IO multiplexers event loop once the stream has been started.

◆ flush()

void caf::io::network::stream::flush ( const manager_ptr mgr)

Sends the content of the write buffer, calling the io_failure member function of mgr in case of an error.

Warning
Must not be called outside the IO multiplexers event loop once the stream has been started.

◆ rd_buf()

byte_buffer& caf::io::network::stream::rd_buf ( )

Returns the read buffer of this stream.

Warning
Must not be modified outside the IO multiplexers event loop once the stream has been started.

◆ wr_buf()

byte_buffer& caf::io::network::stream::wr_buf ( )

Returns the write buffer of this stream.

Warning
Must not be modified outside the IO multiplexers event loop once the stream has been started.

◆ write()

void caf::io::network::stream::write ( const void *  buf,
size_t  num_bytes 
)

Copies data to the write buffer.

Warning
Not thread safe.

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