libcaf  0.14.4
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
caf::io::network::multiplexer Class Referenceabstract

Low-level backend for IO multiplexing. More...

#include <multiplexer.hpp>

Inheritance diagram for caf::io::network::multiplexer:
caf::io::network::asio_multiplexer

Classes

struct  runnable
 Simple wrapper for runnables. More...
 
class  supervisor
 Makes sure the multipler does not exit its event loop until the destructor of supervisor has been called. More...
 

Public Types

using runnable_ptr = intrusive_ptr< runnable >
 
using supervisor_ptr = std::unique_ptr< supervisor >
 

Public Member Functions

virtual connection_handle new_tcp_scribe (const std::string &host, uint16_t port)=0
 Tries to connect to host on given port and returns an unbound connection handle on success. More...
 
virtual void assign_tcp_scribe (abstract_broker *ptr, connection_handle hdl)=0
 Assigns an unbound scribe identified by hdl to ptr. More...
 
virtual connection_handle add_tcp_scribe (abstract_broker *ptr, native_socket fd)=0
 Creates a new TCP doorman from a native socket handle. More...
 
virtual connection_handle add_tcp_scribe (abstract_broker *ptr, const std::string &host, uint16_t port)=0
 Tries to connect to host h on given port and returns a new scribe managing the connection on success. More...
 
virtual std::pair< accept_handle, uint16_t > new_tcp_doorman (uint16_t port, const char *in=nullptr, bool reuse_addr=false)=0
 Tries to create an unbound TCP doorman running port, optionally accepting only connections from IP address in. More...
 
virtual void assign_tcp_doorman (abstract_broker *ptr, accept_handle hdl)=0
 Assigns an unbound doorman identified by hdl to ptr. More...
 
virtual accept_handle add_tcp_doorman (abstract_broker *ptr, native_socket fd)=0
 Creates a new TCP doorman from a native socket handle. More...
 
virtual std::pair< accept_handle, uint16_t > add_tcp_doorman (abstract_broker *ptr, uint16_t port, const char *in=nullptr, bool reuse_addr=false)=0
 Tries to create a new TCP doorman running on port p, optionally accepting only connections from IP address in. More...
 
virtual supervisor_ptr make_supervisor ()=0
 Creates a supervisor to keep the event loop running.
 
virtual void run ()=0
 Runs the multiplexers event loop.
 
template<class F >
void dispatch (F fun)
 Invokes fun in the multiplexer's event loop, calling fun() immediately when called from inside the event loop. More...
 
template<class F >
void post (F fun)
 Invokes fun in the multiplexer's event loop, forcing execution to be delayed when called from inside the event loop. More...
 
virtual boost::asio::io_service * pimpl ()
 Retrieves a pointer to the implementation or nullptr if CAF was compiled using the default backend. More...
 
const std::thread::id & thread_id () const
 
void thread_id (std::thread::id tid)
 

Static Public Member Functions

static std::unique_ptr< multiplexermake ()
 Creates an instance using the networking backend compiled with CAF.
 

Protected Member Functions

virtual void dispatch_runnable (runnable_ptr ptr)=0
 Implementation-specific dispatching to the multiplexer's thread.
 

Protected Attributes

std::thread::id tid_
 Must be set by the subclass.
 

Detailed Description

Low-level backend for IO multiplexing.

Member Function Documentation

virtual accept_handle caf::io::network::multiplexer::add_tcp_doorman ( abstract_broker ptr,
native_socket  fd 
)
pure virtual

Creates a new TCP doorman from a native socket handle.

Warning
Do not call from outside the multiplexer's event loop.

Implemented in caf::io::network::asio_multiplexer.

virtual std::pair<accept_handle, uint16_t> caf::io::network::multiplexer::add_tcp_doorman ( abstract_broker ptr,
uint16_t  port,
const char *  in = nullptr,
bool  reuse_addr = false 
)
pure virtual

Tries to create a new TCP doorman running on port p, optionally accepting only connections from IP address in.

Warning
Do not call from outside the multiplexer's event loop.

Implemented in caf::io::network::asio_multiplexer.

virtual connection_handle caf::io::network::multiplexer::add_tcp_scribe ( abstract_broker ptr,
native_socket  fd 
)
pure virtual

Creates a new TCP doorman from a native socket handle.

Warning
Do not call from outside the multiplexer's event loop.

Implemented in caf::io::network::asio_multiplexer.

virtual connection_handle caf::io::network::multiplexer::add_tcp_scribe ( abstract_broker ptr,
const std::string &  host,
uint16_t  port 
)
pure virtual

Tries to connect to host h on given port and returns a new scribe managing the connection on success.

Warning
Do not call from outside the multiplexer's event loop.

Implemented in caf::io::network::asio_multiplexer.

virtual void caf::io::network::multiplexer::assign_tcp_doorman ( abstract_broker ptr,
accept_handle  hdl 
)
pure virtual

Assigns an unbound doorman identified by hdl to ptr.

Warning
Do not call from outside the multiplexer's event loop.

Implemented in caf::io::network::asio_multiplexer.

virtual void caf::io::network::multiplexer::assign_tcp_scribe ( abstract_broker ptr,
connection_handle  hdl 
)
pure virtual

Assigns an unbound scribe identified by hdl to ptr.

Warning
Do not call from outside the multiplexer's event loop.

Implemented in caf::io::network::asio_multiplexer.

template<class F >
void caf::io::network::multiplexer::dispatch ( fun)

Invokes fun in the multiplexer's event loop, calling fun() immediately when called from inside the event loop.

virtual std::pair<accept_handle, uint16_t> caf::io::network::multiplexer::new_tcp_doorman ( uint16_t  port,
const char *  in = nullptr,
bool  reuse_addr = false 
)
pure virtual

Tries to create an unbound TCP doorman running port, optionally accepting only connections from IP address in.

Warning
Do not call from outside the multiplexer's event loop.

Implemented in caf::io::network::asio_multiplexer.

virtual connection_handle caf::io::network::multiplexer::new_tcp_scribe ( const std::string &  host,
uint16_t  port 
)
pure virtual

Tries to connect to host on given port and returns an unbound connection handle on success.

Implemented in caf::io::network::asio_multiplexer.

virtual boost::asio::io_service* caf::io::network::multiplexer::pimpl ( )
virtual

Retrieves a pointer to the implementation or nullptr if CAF was compiled using the default backend.

Reimplemented in caf::io::network::asio_multiplexer.

template<class F >
void caf::io::network::multiplexer::post ( fun)

Invokes fun in the multiplexer's event loop, forcing execution to be delayed when called from inside the event loop.


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