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

Multiplexes any number of socket_manager objects with a socket. More...

#include <multiplexer.hpp>

Inheritance diagram for caf::net::multiplexer:
caf::async::execution_context

Public Types

using super = async::execution_context
 
using steady_time_point = std::chrono::steady_clock::time_point
 A time point of the monotonic clock.
 

Public Member Functions

virtual error init ()=0
 
std::thread launch ()
 Utility function for running the multiplexer in a background thread.
 
virtual void schedule (steady_time_point when, action what)=0
 Schedules what to run after reaching when on the event loop of the execution context.
 
virtual size_t num_socket_managers () const noexcept=0
 Returns the number of currently active socket managers.
 
virtual middlemanowner ()=0
 Returns the owning middleman instance.
 
virtual actor_systemsystem ()=0
 Returns the enclosing actor_system.
 
virtual void start (socket_manager_ptr mgr)=0
 Registers mgr for initialization in the multiplexer's thread.
 
virtual void shutdown ()=0
 Signals the multiplexer to initiate shutdown.
 
virtual void register_reading (socket_manager *mgr)=0
 Registers mgr for read events.
 
virtual void register_writing (socket_manager *mgr)=0
 Registers mgr for write events.
 
virtual void deregister_reading (socket_manager *mgr)=0
 Deregisters mgr from read events.
 
virtual void deregister_writing (socket_manager *mgr)=0
 Deregisters mgr from write events.
 
virtual void deregister (socket_manager *mgr)=0
 Deregisters mgr from read and write events.
 
virtual bool is_reading (const socket_manager *mgr) const noexcept=0
 Queries whether mgr is currently registered for reading.
 
virtual bool is_writing (const socket_manager *mgr) const noexcept=0
 Queries whether mgr is currently registered for writing.
 
virtual bool poll_once (bool blocking)=0
 Polls I/O activity once and runs all socket event handlers that become ready as a result.
 
virtual void apply_updates ()=0
 Applies all pending updates.
 
virtual void set_thread_id ()=0
 Sets the thread ID to std::this_thread::id().
 
virtual void run ()=0
 Runs the multiplexer until no socket event handler remains active.
 
virtual void schedule (action what)=0
 Schedules what to run on the event loop of the execution context.
 
- 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.
 
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 void block_sigpipe ()
 Blocks the PIPE signal on the current thread when running on Linux.
 
static multiplexerfrom (actor_system &sys)
 Returns a pointer to the multiplexer from the actor system.
 
static multiplexer_ptr make (middleman *parent)
 Creates a new multiplexer instance with the default implementation.
 

Additional Inherited Members

Detailed Description

Multiplexes any number of socket_manager objects with a socket.

Member Function Documentation

◆ block_sigpipe()

void caf::net::multiplexer::block_sigpipe ( )
static

Blocks the PIPE signal on the current thread when running on Linux.

Has no effect otherwise.

◆ launch()

std::thread caf::net::multiplexer::launch ( )

Utility function for running the multiplexer in a background thread.

Precondition
init() has been called prior to invoking this function.

◆ make()

multiplexer_ptr caf::net::multiplexer::make ( middleman * parent)
static

Creates a new multiplexer instance with the default implementation.

Parameters
parentPoints to the owning middleman instance. May be nullptr only for the purpose of unit testing if no socket_manager requires access to the middleman or the actor_system.

◆ schedule() [1/2]

virtual void caf::async::execution_context::schedule ( action what)
virtual

Schedules what to run on the event loop of the execution context.

This member function may get called from external sources or threads. @thread-safe

Implements caf::async::execution_context.

◆ schedule() [2/2]

virtual void caf::net::multiplexer::schedule ( steady_time_point when,
action what )
pure virtual

Schedules what to run after reaching when on the event loop of the execution context.

This member function may get called from external sources or threads. @thread-safe

◆ shutdown()

virtual void caf::net::multiplexer::shutdown ( )
pure virtual

Signals the multiplexer to initiate shutdown.

@thread-safe

◆ start()

virtual void caf::net::multiplexer::start ( socket_manager_ptr mgr)
pure virtual

Registers mgr for initialization in the multiplexer's thread.

@thread-safe


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