C++ Actor Framework 0.19
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Related Functions | List of all members
caf::net::socket_manager Class Reference

Manages the lifetime of a single socket and handles any I/O events on it. More...

#include <socket_manager.hpp>

Inheritance diagram for caf::net::socket_manager:
caf::detail::atomic_ref_counted

Public Types

using event_handler_ptr = std::unique_ptr< socket_event_layer >
 

Public Member Functions

 socket_manager (multiplexer *mpx, event_handler_ptr handler)
 
 socket_manager (const socket_manager &)=delete
 
socket_manageroperator= (const socket_manager &)=delete
 
socket handle () const
 Returns the handle for the managed socket.
 
actor_systemsystem () noexcept
 Returns a reference to the hosting actor_system instance.
 
multiplexermpx () noexcept
 Returns the owning multiplexer instance.
 
const multiplexermpx () const noexcept
 Returns the owning multiplexer instance.
 
multiplexermpx_ptr () noexcept
 Returns a pointer to the owning multiplexer instance.
 
const multiplexermpx_ptr () const noexcept
 Returns a pointer to the owning multiplexer instance.
 
bool is_reading () const noexcept
 Queries whether the manager is registered for reading.
 
bool is_writing () const noexcept
 Queries whether the manager is registered for writing.
 
void register_reading ()
 Registers the manager for read operations.
 
void register_writing ()
 Registers the manager for write operations.
 
void deregister_reading ()
 Deregisters the manager from read operations.
 
void deregister_writing ()
 Deregisters the manager from write operations.
 
void deregister ()
 Deregisters the manager from both read and write operations.
 
void add_cleanup_listener (action fn)
 Schedules a call to fn on the multiplexer when this socket manager cleans up its state.
 
void schedule_handover ()
 Schedules a call to do_handover on the handler.
 
void schedule (action what)
 Schedules what to run later.
 
template<class F >
void schedule_fn (F &&what)
 Schedules what to run later.
 
void shutdown ()
 Shuts down this socket manager.
 
error start ()
 Starts the manager and its all of its processing layers.
 
void handle_read_event ()
 Called whenever the socket received new data.
 
void handle_write_event ()
 Called whenever the socket is allowed to send data.
 
void handle_error (sec code)
 Called when the remote side becomes unreachable due to an error or after calling dispose.
 
void dispose () override
 
bool disposed () const noexcept override
 
void ref_disposable () const noexcept override
 
void deref_disposable () const noexcept override
 
- Public Member Functions inherited from caf::detail::atomic_ref_counted
 atomic_ref_counted (const atomic_ref_counted &)
 
atomic_ref_countedoperator= (const atomic_ref_counted &)
 
void ref () const noexcept
 Increases reference count by one.
 
void deref () const noexcept
 Decreases reference count by one and calls request_deletion when it drops to zero.
 
bool unique () const noexcept
 Queries whether there is exactly one reference.
 
size_t get_reference_count () const noexcept
 Queries the current reference count for this object.
 

Static Public Member Functions

static socket_manager_ptr make (multiplexer *mpx, event_handler_ptr handler)
 

Related Functions

(Note that these are not member functions.)

using socket_manager_ptr = intrusive_ptr< socket_manager >
 

Additional Inherited Members

- Protected Attributes inherited from caf::detail::atomic_ref_counted
std::atomic< size_t > rc_
 

Detailed Description

Manages the lifetime of a single socket and handles any I/O events on it.

Constructor & Destructor Documentation

◆ socket_manager()

caf::net::socket_manager::socket_manager ( multiplexer mpx,
event_handler_ptr  handler 
)
Precondition
handle != invalid_socket
mpx!= nullptr

Member Function Documentation

◆ add_cleanup_listener()

void caf::net::socket_manager::add_cleanup_listener ( action  fn)

Schedules a call to fn on the multiplexer when this socket manager cleans up its state.

Note
Must be called before start.

◆ handle_error()

void caf::net::socket_manager::handle_error ( sec  code)

Called when the remote side becomes unreachable due to an error or after calling dispose.

Parameters
codeThe error code as reported by the operating system or sec::disposed.

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