C++ Actor Framework 1.0.0
Loading...
Searching...
No Matches
caf::net::socket_manager Class Referenceabstract

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 caf::flow::coordinator caf::async::execution_context

Public Types

using event_handler_ptr = std::unique_ptr<socket_event_layer>
 
- Public Types inherited from caf::flow::coordinator
using steady_time_point = std::chrono::steady_clock::time_point
 A time point of the monotonic clock.
 

Public Member Functions

virtual socket handle () const =0
 Returns the handle for the managed socket.
 
multiplexermpx () const
 Returns the owning multiplexer instance.
 
virtual multiplexermpx_ptr () const noexcept=0
 Returns a pointer to the owning multiplexer instance.
 
virtual bool is_reading () const noexcept=0
 Queries whether the manager is registered for reading.
 
virtual bool is_writing () const noexcept=0
 Queries whether the manager is registered for writing.
 
virtual void register_reading ()=0
 Registers the manager for read operations.
 
virtual void register_writing ()=0
 Registers the manager for write operations.
 
virtual void deregister_reading ()=0
 Deregisters the manager from read operations.
 
virtual void deregister_writing ()=0
 Deregisters the manager from write operations.
 
virtual void deregister ()=0
 Deregisters the manager from both read and write operations.
 
virtual void add_cleanup_listener (action fn)=0
 Schedules a call to fn on the multiplexer when this socket manager cleans up its state.
 
virtual void schedule_handover ()=0
 Schedules a call to do_handover on the handler.
 
virtual void shutdown ()=0
 Shuts down this socket manager.
 
virtual error start ()=0
 Starts the manager and its all of its processing layers.
 
virtual void handle_read_event ()=0
 Called whenever the socket received new data.
 
virtual void handle_write_event ()=0
 Called whenever the socket is allowed to send data.
 
virtual void handle_error (sec code)=0
 Called when the remote side becomes unreachable due to an error or after calling dispose.
 
- 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.
 
- Public Member Functions inherited from caf::flow::coordinator
observable_builder make_observable ()
 Returns a factory object for new observable objects on this coordinator.
 
template<class Impl , class... Args>
std::enable_if_t< std::is_base_of_v< coordinated, Impl >, intrusive_ptr< Impl > > add_child (std::in_place_type_t< Impl >, Args &&... args)
 Creates a new coordinated object on this coordinator.
 
template<class Impl , class... Args>
std::enable_if_t< std::is_base_of_v< coordinated, Impl >, typename Impl::handle_type > add_child_hdl (std::in_place_type_t< Impl > token, Args &&... args)
 Like add_child, but wraps the result in a handle type.
 
virtual void release_later (coordinated_ptr &child)=0
 Resets child and releases the reference count of the coordinated object at the end of the current cycle.
 
template<class T >
std::enable_if_t< std::is_base_of_v< coordinated, T > > release_later (intrusive_ptr< T > &child)
 Resets child and releases the reference count of the coordinated object at the end of the current cycle.
 
template<class Handle >
std::enable_if< Handle::holds_coordinated > release_later (Handle &hdl)
 Resets hdl and releases the reference count of the coordinated object at the end of the current cycle.
 
virtual steady_time_point steady_time ()=0
 Returns the current time on the monotonic clock of this coordinator.
 
virtual void delay (action what)=0
 Delays execution of an action until all pending actions were executed.
 
template<class F >
void delay_fn (F &&what)
 Delays execution of an action until all pending actions were executed.
 
virtual disposable delay_until (steady_time_point abs_time, action what)=0
 Delays execution of an action with an absolute timeout.
 
template<class F >
disposable delay_until_fn (steady_time_point abs_time, F &&what)
 Delays execution of an action until all pending actions were executed.
 
disposable delay_for (timespan rel_time, action what)
 Delays execution of an action with a relative timeout.
 
template<class F >
disposable delay_for_fn (timespan rel_time, F &&what)
 Delays execution of an action with a relative timeout.
 
- Public Member Functions inherited from caf::async::execution_context
virtual void ref_execution_context () const noexcept=0
 Increases the reference count of the execution_context.
 
virtual void deref_execution_context () const noexcept=0
 Decreases the reference count of the execution context and destroys the object if necessary.
 
virtual void schedule (action what)=0
 Schedules what to run on the event loop of the execution context.
 
template<class F >
void schedule_fn (F &&what)
 Schedules what to run on the event loop of the execution context.
 
virtual void watch (disposable what)=0
 Asks the coordinator to keep its event loop running until what becomes disposed since it depends on external events or produces events that are visible to outside observers.
 

Static Public Member Functions

static socket_manager_ptr make (multiplexer *mpx, event_handler_ptr handler)
 

Friends

class abstract_actor_shell
 

Related Symbols

(Note that these are not member symbols.)

using socket_manager_ptr = intrusive_ptr<socket_manager>
 
CAF_NET_EXPORT void intrusive_ptr_add_ref (socket_manager *ptr) noexcept
 
CAF_NET_EXPORT void intrusive_ptr_release (socket_manager *ptr) noexcept
 

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.

Member Function Documentation

◆ add_cleanup_listener()

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

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

Note
Must be called before start.

◆ handle_error()

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

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 files: