C++ Actor Framework 1.0.0
|
Describes a dynamically typed broker. More...
#include <broker.hpp>
Public Types | |
using | super = extended_base |
using | signatures = none_t |
using | behavior_type = behavior |
Public Member Functions | |
template<class F , class... Ts> | |
infer_handle_from_fun_t< F > | fork (F fun, connection_handle hdl, Ts &&... xs) |
void | initialize () override |
template<class... Args> | |
auto | mail (Args &&... args) |
Starts a new message. | |
template<class T , class... Ts> | |
void | become (T &&arg, Ts &&... args) |
Changes the behavior of this actor. | |
void | unbecome () |
Removes the last added behavior. | |
Public Member Functions inherited from caf::io::abstract_broker | |
abstract_broker (abstract_broker &&)=delete | |
abstract_broker (const abstract_broker &&)=delete | |
abstract_broker & | operator= (abstract_broker &&)=delete |
abstract_broker & | operator= (const abstract_broker &&)=delete |
bool | enqueue (mailbox_element_ptr, scheduler *) override |
void | launch (scheduler *eu, bool lazy, bool hide) override |
void | on_cleanup (const error &reason) override |
resume_result | resume (scheduler *, size_t) override |
template<class Handle > | |
void | halt (Handle hdl) |
Suspends activities on hdl unconditionally. | |
template<class Handle > | |
void | trigger (Handle hdl) |
Allows activities on hdl unconditionally (default). | |
template<class Handle > | |
void | trigger (Handle hdl, size_t num_events) |
Allows num_events activities on hdl . | |
void | configure_read (connection_handle hdl, receive_policy::config cfg) |
Modifies the receive policy for a given connection. | |
void | ack_writes (connection_handle hdl, bool enable) |
Enables or disables write notifications for a given connection. | |
byte_buffer & | wr_buf (connection_handle hdl) |
Returns the write buffer for a given connection. | |
void | write (connection_handle hdl, size_t bs, const void *buf) |
Writes data into the buffer for a given connection. | |
void | write (connection_handle hdl, span< const std::byte > buf) |
Writes buf into the buffer for a given connection. | |
void | flush (connection_handle hdl) |
Sends the content of the buffer for a given connection. | |
void | ack_writes (datagram_handle hdl, bool enable) |
Enables or disables write notifications for a given datagram socket. | |
byte_buffer & | wr_buf (datagram_handle hdl) |
Returns the write buffer for a given sink. | |
void | enqueue_datagram (datagram_handle, byte_buffer) |
Enqueue a buffer to be sent as a datagram via a given endpoint. | |
void | write (datagram_handle hdl, size_t data_size, const void *data) |
Writes data into the buffer of a given sink. | |
void | flush (datagram_handle hdl) |
Sends the content of the buffer to a UDP endpoint. | |
middleman & | parent () |
Returns the middleman instance this broker belongs to. | |
void | add_scribe (scribe_ptr ptr) |
Adds the uninitialized scribe instance ptr to this broker. | |
connection_handle | add_scribe (network::native_socket fd) |
Creates and assigns a new scribe from given native socked fd . | |
expected< connection_handle > | add_tcp_scribe (const std::string &host, uint16_t port) |
Tries to connect to host on given port and creates a new scribe describing the connection afterwards. | |
void | move_scribe (scribe_ptr ptr) |
Moves the initialized scribe instance ptr from another broker to this broker. | |
void | add_doorman (doorman_ptr ptr) |
Adds a doorman instance to this broker. | |
accept_handle | add_doorman (network::native_socket fd) |
Creates and assigns a new doorman from given native socked fd . | |
void | move_doorman (doorman_ptr ptr) |
Adds a doorman instance to this broker. | |
expected< std::pair< accept_handle, uint16_t > > | add_tcp_doorman (uint16_t port=0, const char *in=nullptr, bool reuse_addr=false) |
Tries to open a local port and creates a doorman managing it on success. | |
void | add_datagram_servant (datagram_servant_ptr ptr) |
Adds a datagram_servant to this broker. | |
void | add_hdl_for_datagram_servant (datagram_servant_ptr ptr, datagram_handle hdl) |
Adds the datagram_servant under an additional hdl . | |
datagram_handle | add_datagram_servant (network::native_socket fd) |
Creates and assigns a new datagram_servant from a given socket fd . | |
datagram_handle | add_datagram_servant_for_endpoint (network::native_socket fd, const network::ip_endpoint &ep) |
Creates and assigns a new datagram_servant from a given socket fd for the remote endpoint ep . | |
expected< datagram_handle > | add_udp_datagram_servant (const std::string &host, uint16_t port) |
Creates a new datagram_servant for the remote endpoint host and port . | |
expected< std::pair< datagram_handle, uint16_t > > | add_udp_datagram_servant (uint16_t port=0, const char *in=nullptr, bool reuse_addr=false) |
Tries to open a local port and creates a datagram_servant managing it on success. | |
void | move_datagram_servant (datagram_servant_ptr ptr) |
Moves an initialized datagram_servant instance ptr from another broker to this one. | |
std::string | remote_addr (connection_handle hdl) |
Returns the remote address associated with hdl or empty string if hdl is invalid. | |
uint16_t | remote_port (connection_handle hdl) |
Returns the remote port associated with hdl or 0 if hdl is invalid. | |
std::string | local_addr (accept_handle hdl) |
Returns the local address associated with hdl or empty string if hdl is invalid. | |
uint16_t | local_port (accept_handle hdl) |
Returns the local port associated with hdl or 0 if hdl is invalid. | |
accept_handle | hdl_by_port (uint16_t port) |
Returns the handle associated with given local port or none . | |
datagram_handle | datagram_hdl_by_port (uint16_t port) |
Returns the dgram handle associated with given local port or none . | |
std::string | remote_addr (datagram_handle hdl) |
Returns the remote address associated with hdl or an empty string if hdl is invalid. | |
uint16_t | remote_port (datagram_handle hdl) |
Returns the remote port associated with hdl or 0 if hdl is invalid. | |
uint16_t | local_port (datagram_handle hdl) |
Returns the remote port associated with hdl or 0 if hdl is invalid. | |
bool | remove_endpoint (datagram_handle hdl) |
Remove the endpoint hdl from the broker. | |
void | close_all () |
Closes all connections and acceptors. | |
template<class Handle > | |
bool | close (Handle hdl) |
Closes the connection or acceptor identified by handle . | |
template<class Handle > | |
bool | valid (Handle hdl) |
Checks whether hdl is assigned to broker. | |
const char * | name () const override |
subtype_t | subtype () const noexcept override |
size_t | num_connections () const noexcept |
Returns the number of open connections. | |
size_t | num_doormen () const noexcept |
Returns the number of attached doorman for accepting incoming connections. | |
std::vector< connection_handle > | connections () const |
Returns all handles of all scribe instances attached to this broker. | |
network::multiplexer & | backend () |
Returns the multiplexer running this broker. | |
Protected Member Functions | |
virtual behavior | make_behavior () |
Protected Member Functions inherited from caf::io::abstract_broker | |
void | init_broker () |
abstract_broker (actor_config &cfg) | |
template<class Handle > | |
auto | by_id (Handle hdl) -> decltype(ptr_of(hdl)) |
Returns a scribe or doorman identified by hdl . | |
Additional Inherited Members | |
Protected Types inherited from caf::io::abstract_broker | |
using | doorman_map = std::unordered_map<accept_handle, intrusive_ptr<doorman>> |
using | scribe_map = std::unordered_map<connection_handle, intrusive_ptr<scribe>> |
using | datagram_servant_map = std::unordered_map<datagram_handle, intrusive_ptr<datagram_servant>> |
Describes a dynamically typed broker.
void caf::io::broker::become | ( | T && | arg, |
Ts &&... | args ) |
Changes the behavior of this actor.
void caf::io::broker::unbecome | ( | ) |
Removes the last added behavior.
Terminates the actor if there are no behaviors left.