actor-framework
|
A broker implementation for the Binary Actor System Protocol (BASP). More...
#include <basp_broker.hpp>
Public Types | |
using | super = broker |
using | ctx_map = std::unordered_map< connection_handle, basp::endpoint_context > |
using | monitored_actor_map = std::unordered_map< actor_addr, std::unordered_set< node_id > > |
Public Types inherited from caf::io::broker | |
using | super = extended_base |
using | signatures = none_t |
using | behavior_type = behavior |
Public Types inherited from caf::scheduled_actor | |
enum | message_category { message_category::ordinary, message_category::internal, message_category::skipped } |
Categorizes incoming messages. More... | |
enum | activation_result { activation_result::success, activation_result::terminated, activation_result::skipped, activation_result::dropped } |
Result of one-shot activations. More... | |
using | super = abstract_scheduled_actor |
Base type. | |
using | batch_op_ptr = intrusive_ptr< flow::op::base< async::batch > > |
using | pending_response = std::tuple< const message_id, behavior, disposable > |
The message ID of an outstanding response with its callback and timeout. | |
using | pointer = scheduled_actor * |
A pointer to a scheduled actor. | |
using | default_handler = std::function< skippable_result(pointer, message &)> |
Function object for handling unmatched messages. | |
using | error_handler = std::function< void(pointer, error &)> |
Function object for handling error messages. | |
using | down_handler = std::function< void(pointer, down_msg &)> |
Function object for handling down messages. | |
using | node_down_handler = std::function< void(pointer, node_down_msg &)> |
Function object for handling node down messages. | |
using | exit_handler = std::function< void(pointer, exit_msg &)> |
Function object for handling exit messages. | |
using | idle_handler = std::function< void()> |
Function object for handling timeouts. | |
using | batch_publisher = flow::multicaster< async::batch > |
using | batch_forwarder_ptr = intrusive_ptr< batch_forwarder > |
Public Types inherited from caf::abstract_scheduled_actor | |
using | super = local_actor |
Public Types inherited from caf::local_actor | |
using | clock_type = std::chrono::steady_clock |
Defines a monotonic clock suitable for measuring intervals. | |
Public Types inherited from caf::resumable | |
enum | resume_result { resume_later, awaiting_message, done, shutdown_execution_unit } |
Denotes the state in which a resumable returned from its last call to resume . More... | |
enum | subtype_t { unspecified, scheduled_actor, io_actor, function_object } |
Denotes common subtypes of resumable . More... | |
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 | |
basp_broker (actor_config &cfg) | |
void | on_exit () override |
Can be overridden to perform cleanup code after an actor finished execution. More... | |
const char * | name () const override |
Returns an implementation-dependent name for logging purposes, which is only valid as long as the actor is running. More... | |
behavior | make_behavior () override |
proxy_registry * | proxy_registry_ptr () override |
Returns a factory for proxies created and managed by this actor or nullptr . More... | |
resume_result | resume (scheduler *, size_t) override |
Resume any pending computation until it is either finished or needs to be re-scheduled later. More... | |
strong_actor_ptr | make_proxy (node_id nid, actor_id aid) override |
Creates a new proxy instance. | |
void | set_last_hop (node_id *ptr) override |
Sets the thread-local last-hop pointer to detect indirect connections. | |
void | finalize_handshake (const node_id &nid, actor_id aid, std::set< std::string > &sigs) override |
Called if a server handshake was received and the connection to nid is established. More... | |
void | purge_state (const node_id &nid) override |
Called whenever a direct connection was closed or a node became unreachable for other reasons before this node gets erased from the routing table. More... | |
void | proxy_announced (const node_id &nid, actor_id aid) override |
Called whenever a remote node created a proxy for one of our local actors. More... | |
void | learned_new_node_directly (const node_id &nid, bool was_indirectly_before) override |
Called whenever BASP learns the ID of a remote node to which it does not have a direct connection. More... | |
void | learned_new_node_indirectly (const node_id &nid) override |
Called whenever BASP learns the ID of a remote node to which it does not have a direct connection. More... | |
byte_buffer & | get_buffer (connection_handle hdl) override |
Returns a reference to the sent buffer. | |
void | flush (connection_handle hdl) override |
Flushes the underlying write buffer of hdl . | |
void | handle_heartbeat () override |
Called if a heartbeat was received from nid | |
scheduler * | current_scheduler () override |
Returns the current CAF scheduler context. | |
strong_actor_ptr | this_actor () override |
Returns a handle to the callee actor. | |
void | emit_node_down_msg (const node_id &node, const error &reason) |
Sends node_down_msg to all registered observers. | |
void | learned_new_node (const node_id &nid) |
Performs bookkeeping such as managing spawn_servers . | |
void | set_context (connection_handle hdl) |
Sets this_context by either creating or accessing state for hdl . More... | |
void | connection_cleanup (connection_handle hdl, sec code) |
Cleans up any state for hdl . | |
void | send_basp_down_message (const node_id &nid, actor_id aid, error err) |
Sends a basp::down_message message to a remote node. | |
void | handle_down_msg (down_msg &) |
actor_system & | system () |
const actor_system_config & | config () |
const node_id & | this_node () const |
Returns the node identifier of the underlying BASP instance. | |
Public Member Functions inherited from caf::io::broker | |
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. More... | |
void | unbecome () |
Removes the last added behavior. More... | |
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 |
Enqueues a new message wrapped in a mailbox_element to the actor. More... | |
void | launch (scheduler *eu, bool lazy, bool hide) override |
void | on_cleanup (const error &reason) override |
Called from cleanup to perform extra cleanup actions for this actor. | |
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. More... | |
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. More... | |
void | move_scribe (scribe_ptr ptr) |
Moves the initialized scribe instance ptr from another broker to this broker. More... | |
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. More... | |
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 . More... | |
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 . More... | |
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. More... | |
void | move_datagram_servant (datagram_servant_ptr ptr) |
Moves an initialized datagram_servant instance ptr from another broker to this one. More... | |
std::string | remote_addr (connection_handle hdl) |
Returns the remote address associated with hdl or empty string if hdl is invalid. More... | |
uint16_t | remote_port (connection_handle hdl) |
Returns the remote port associated with hdl or 0 if hdl is invalid. More... | |
std::string | local_addr (accept_handle hdl) |
Returns the local address associated with hdl or empty string if hdl is invalid. More... | |
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. More... | |
uint16_t | remote_port (datagram_handle hdl) |
Returns the remote port associated with hdl or 0 if hdl is invalid. More... | |
uint16_t | local_port (datagram_handle hdl) |
Returns the remote port associated with hdl or 0 if hdl is invalid. More... | |
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 . More... | |
template<class Handle > | |
bool | valid (Handle hdl) |
Checks whether hdl is assigned to broker. | |
subtype_t | subtype () const noexcept override |
Returns a subtype hint for this object. More... | |
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. | |
Public Member Functions inherited from caf::scheduled_actor | |
scheduled_actor (actor_config &cfg) | |
scheduled_actor (scheduled_actor &&)=delete | |
scheduled_actor (const scheduled_actor &)=delete | |
scheduled_actor & | operator= (scheduled_actor &&)=delete |
scheduled_actor & | operator= (const scheduled_actor &)=delete |
mailbox_element * | peek_at_next_mailbox_element () override |
Called by the testing DSL to peek at the next element in the mailbox. More... | |
void | ref_resumable () const noexcept final |
Add a strong reference count to this object. | |
void | deref_resumable () const noexcept final |
Remove a strong reference count from this object. | |
void | quit (error x=error{}) |
Finishes execution of this actor after any currently running message handler is done. More... | |
abstract_mailbox & | mailbox () noexcept |
Returns the queue for storing incoming messages. | |
bool | initialized () const noexcept |
Checks whether this actor is fully initialized. | |
bool | inactive () const noexcept |
Checks whether this actor is currently inactive, i.e., not ready to run. | |
void | set_default_handler (default_handler fun) |
Sets a custom handler for unexpected messages. | |
template<class F > | |
std::enable_if_t< std::is_invocable_r_v< skippable_result, F, message & > > | set_default_handler (F fun) |
Sets a custom handler for unexpected messages. | |
void | set_error_handler (error_handler fun) |
Sets a custom handler for error messages. | |
template<class F > | |
std::enable_if_t< std::is_invocable_v< F, error & > > | set_error_handler (F fun) |
Sets a custom handler for error messages. | |
void | set_down_handler (down_handler fun) |
Sets a custom handler for down messages. | |
template<class F > | |
std::enable_if_t< std::is_invocable_v< F, down_msg & > > | set_down_handler (F fun) |
Sets a custom handler for down messages. | |
void | set_node_down_handler (node_down_handler fun) |
Sets a custom handler for node down messages. | |
template<class F > | |
std::enable_if_t< std::is_invocable_v< F, node_down_msg & > > | set_node_down_handler (F fun) |
Sets a custom handler for down messages. | |
void | set_exit_handler (exit_handler fun) |
Sets a custom handler for error messages. | |
template<class F > | |
std::enable_if_t< std::is_invocable_v< F, exit_msg & > > | set_exit_handler (F fun) |
Sets a custom handler for exit messages. | |
template<class RefType , class RepeatType > | |
void | set_idle_handler (timespan delay, RefType, RepeatType, idle_handler fun) |
Sets a custom handler for timeouts that trigger after not receiving a message for a certain amount of time. More... | |
Public Member Functions inherited from caf::abstract_scheduled_actor | |
virtual void | add_awaited_response_handler (message_id response_id, behavior bhvr, disposable pending_timeout={})=0 |
Adds a callback for an awaited response. | |
virtual void | add_multiplexed_response_handler (message_id response_id, behavior bhvr, disposable pending_timeout={})=0 |
Adds a callback for a multiplexed response. | |
virtual void | call_error_handler (error &what)=0 |
Calls the default error handler. | |
virtual void | run_actions ()=0 |
Runs all pending actions. | |
template<class... Ts> | |
auto | response_to_flow_cell (message_id response_id, disposable pending_timeout={}) |
Lifts a response message into a flow cell in order to allow the actor to turn a response into an observable or single . More... | |
Public Member Functions inherited from caf::local_actor | |
local_actor (actor_config &cfg) | |
void | setup_metrics () |
clock_type::time_point | now () const noexcept |
Returns the current time. | |
disposable | request_response_timeout (timespan d, message_id mid) |
Requests a new timeout for mid . More... | |
template<class... Args> | |
void | println (std::string_view fmt, Args &&... args) |
Adds a new line to stdout. | |
template<class... Args> | |
void | println (term color, std::string_view fmt, Args &&... args) |
Adds a new line to stdout. | |
template<class T , spawn_options Os = no_spawn_options, class... Ts> | |
infer_handle_from_class_t< T > | spawn (Ts &&... xs) |
template<spawn_options Options = no_spawn_options, class CustomSpawn , class... Args> | |
CustomSpawn::handle_type | spawn (CustomSpawn, Args &&... args) |
template<spawn_options Os = no_spawn_options, class F , class... Ts> | |
infer_handle_from_fun_t< F > | spawn (F fun, Ts &&... xs) |
void | send_exit (const actor_addr &receiver, error reason) |
Sends an exit message to receiver . | |
void | send_exit (const strong_actor_ptr &receiver, error reason) |
Sends an exit message to receiver . | |
template<class Handle > | |
void | send_exit (const Handle &receiver, error reason) |
Sends an exit message to receiver . | |
template<message_priority Priority = message_priority::normal, class Handle , class T , class... Ts> | |
void | anon_send (const Handle &receiver, T &&arg, Ts &&... args) |
template<message_priority Priority = message_priority::normal, class Handle , class T , class... Ts> | |
disposable | scheduled_anon_send (const Handle &receiver, actor_clock::time_point timeout, T &&arg, Ts &&... args) |
template<message_priority Priority = message_priority::normal, class Handle , class T , class... Ts> | |
disposable | delayed_anon_send (const Handle &receiver, actor_clock::duration_type timeout, T &&arg, Ts &&... args) |
scheduler * | context () const noexcept |
Returns the execution unit currently used by this actor. | |
void | context (scheduler *x) noexcept |
Sets the execution unit for this actor. | |
actor_system & | system () const noexcept |
Returns the hosting actor system. | |
const actor_system_config & | config () const noexcept |
Returns the config of the hosting actor system. | |
actor_clock & | clock () const noexcept |
Returns the clock of the actor system. | |
strong_actor_ptr & | current_sender () noexcept |
Returns a pointer to the sender of the current message. More... | |
message_id | current_message_id () noexcept |
Returns the ID of the current message. | |
message_id | take_current_message_id () noexcept |
Returns the ID of the current message and marks the ID stored in the current mailbox element as answered. More... | |
void | drop_current_message_id () noexcept |
Marks the current message ID as answered. | |
mailbox_element * | current_mailbox_element () noexcept |
Returns a pointer to the currently processed mailbox element. | |
void | monitor (const node_id &node) |
Adds a unidirectional monitor to node . More... | |
template<message_priority P = message_priority::normal, class Handle > | |
void | monitor (const Handle &whom) |
Adds a unidirectional monitor to whom . More... | |
template<typename Handle , typename Fn > | |
disposable | monitor (Handle whom, Fn func) |
Adds a unidirectional monitor to whom with custom callback. More... | |
void | demonitor (const actor_addr &whom) |
Removes a monitor from whom . | |
void | demonitor (const strong_actor_ptr &whom) |
Removes a monitor from whom . | |
void | demonitor (const node_id &node) |
Removes a monitor from node . | |
template<class Handle > | |
void | demonitor (const Handle &whom) |
Removes a monitor from whom . | |
template<class... Ts> | |
detail::response_promise_t< Ts... > | make_response_promise () |
Creates a typed_response_promise to respond to a request later on. More... | |
response_promise | make_response_promise () |
Creates a response_promise to respond to a request later on. | |
virtual error | save_state (serializer &sink, unsigned int version) |
Serializes the state of this actor to sink . More... | |
virtual error | load_state (deserializer &source, unsigned int version) |
Deserializes the state of this actor from source . More... | |
const error & | fail_state () const noexcept |
Returns the currently defined fail state. More... | |
Public Member Functions inherited from caf::abstract_actor | |
abstract_actor (const abstract_actor &)=delete | |
abstract_actor & | operator= (const abstract_actor &)=delete |
void | attach (attachable_ptr ptr) |
Attaches ptr to this actor. More... | |
template<class F > | |
void | attach_functor (F f) |
Convenience function that attaches the functor f to this actor. More... | |
size_t | detach (const attachable::token &what) |
Detaches the first attached object that matches what . | |
void | link_to (const actor_addr &other) |
Links this actor to other . | |
template<class ActorHandle > | |
void | link_to (const ActorHandle &other) |
Links this actor to other . | |
void | unlink_from (const actor_addr &other) |
Unlinks this actor from addr . | |
template<class ActorHandle > | |
void | unlink_from (const ActorHandle &other) |
Links this actor to hdl . | |
virtual std::set< std::string > | message_types () const |
Returns the set of accepted messages types as strings or an empty set if this actor is untyped. More... | |
actor_id | id () const noexcept |
Returns the ID of this actor. | |
node_id | node () const noexcept |
Returns the node this actor is living on. | |
actor_system & | home_system () const noexcept |
Returns the system that created this actor (or proxy). | |
actor_control_block * | ctrl () const |
Returns the control block for this actor. | |
actor_addr | address () const noexcept |
Returns the logical actor address. | |
bool | cleanup (error &&reason, scheduler *sched) |
Called by the runtime system to perform cleanup actions for this actor. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
template<class F > | |
void | delay_fn (F &&what) |
Delays execution of an action until all pending actions were executed. More... | |
virtual disposable | delay_until (steady_time_point abs_time, action what)=0 |
Delays execution of an action with an absolute timeout. More... | |
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. More... | |
disposable | delay_for (timespan rel_time, action what) |
Delays execution of an action with a relative timeout. More... | |
template<class F > | |
disposable | delay_for_fn (timespan rel_time, F &&what) |
Delays execution of an action with a relative timeout. More... | |
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. More... | |
virtual void | schedule (action what)=0 |
Schedules what to run on the event loop of the execution context. More... | |
template<class F > | |
void | schedule_fn (F &&what) |
Schedules what to run on the event loop of the execution context. More... | |
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. More... | |
Public Member Functions inherited from caf::io::basp::instance::callee | |
callee (actor_system &sys, proxy_registry::backend &backend) | |
proxy_registry & | proxies () |
Returns the actor namespace associated to this BASP protocol instance. | |
Public Attributes | |
union { | |
basp::instance instance | |
}; | |
Protocol instance of BASP. | |
ctx_map | ctx |
Keeps context information for all open connections. | |
basp::endpoint_context * | this_context |
points to the current context for callbacks. | |
std::unordered_map< node_id, actor > | spawn_servers |
Stores handles to spawn servers for other nodes. More... | |
std::unordered_map< node_id, std::vector< actor_addr > > | node_observers |
Keeps track of actors that wish to receive a node_down_msg if a particular node fails. More... | |
bool | automatic_connections = false |
Configures whether BASP automatically open new connections to optimize routing paths by forming a mesh between all nodes. More... | |
monitored_actor_map | monitored_actors |
Keeps track of nodes that monitor local actors. | |
Additional Inherited Members | |
Static Public Member Functions inherited from caf::scheduled_actor | |
static void | default_error_handler (pointer ptr, error &x) |
static void | default_down_handler (pointer ptr, down_msg &x) |
static void | default_node_down_handler (pointer ptr, node_down_msg &x) |
static void | default_exit_handler (pointer ptr, exit_msg &x) |
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 > > |
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 . | |
Protected Member Functions inherited from caf::local_actor | |
void | do_send (abstract_actor *receiver, message_priority priority, message &&msg) |
Sends msg as an asynchronous message to receiver . More... | |
disposable | do_scheduled_send (strong_actor_ptr receiver, message_priority priority, actor_clock::time_point timeout, message &&msg) |
Sends msg as an asynchronous message to receiver after the timeout. More... | |
void | do_anon_send (abstract_actor *receiver, message_priority priority, message &&msg) |
Sends msg as an asynchronous message to receiver without sender information. More... | |
disposable | do_scheduled_anon_send (strong_actor_ptr receiver, message_priority priority, actor_clock::time_point timeout, message &&msg) |
Sends msg as an asynchronous message to receiver after the timeout without sender information. More... | |
Protected Member Functions inherited from caf::abstract_actor | |
virtual void | on_unreachable () |
Called on actor if the last strong reference to it expired without a prior call to quit(exit_reason::not_exited) . More... | |
int | flags () const |
void | flags (int new_value) |
bool | is_terminated () const noexcept |
Checks whether this actor has terminated. | |
abstract_actor (actor_config &cfg) | |
void | attach_impl (attachable_ptr &ptr) |
size_t | detach_impl (const attachable::token &what, bool stop_on_hit=false, bool dry_run=false) |
void | add_link (abstract_actor *other) |
Causes the actor to establish a link to other . | |
void | remove_link (abstract_actor *other) |
Causes the actor to remove any established link to other . | |
virtual bool | add_backlink (abstract_actor *other) |
Adds an entry to other to the link table of this actor. More... | |
virtual bool | remove_backlink (abstract_actor *other) |
Removes an entry to other from the link table of this actor. More... | |
Protected Attributes inherited from caf::scheduled_actor | |
abstract_mailbox * | mailbox_ |
Stores incoming messages. | |
detail::behavior_stack | bhvr_stack_ |
Stores user-defined callbacks for message handling. | |
std::forward_list< pending_response > | awaited_responses_ |
Stores callbacks for awaited responses. | |
unordered_flat_map< message_id, std::pair< behavior, disposable > > | multiplexed_responses_ |
Stores callbacks for multiplexed responses. | |
default_handler | default_handler_ |
Customization point for setting a default message callback. | |
error_handler | error_handler_ |
Customization point for setting a default error callback. | |
down_handler | down_handler_ |
Customization point for setting a default down_msg callback. | |
node_down_handler | node_down_handler_ |
Customization point for setting a default down_msg callback. | |
exit_handler | exit_handler_ |
Customization point for setting a default exit_msg callback. | |
detail::private_thread * | private_thread_ |
Pointer to a private thread object associated with a detached actor. | |
Protected Attributes inherited from caf::local_actor | |
scheduler * | context_ |
mailbox_element * | current_element_ |
message_id | last_request_id_ |
detail::unique_function< behavior(local_actor *)> | initial_behavior_fac_ |
Factory function for returning initial behavior in function-based actors. | |
metrics_t | metrics_ |
Protected Attributes inherited from caf::abstract_actor | |
std::atomic< int > | flags_ |
Holds several state and type flags. | |
std::mutex | mtx_ |
Guards members that may be subject to concurrent access . More... | |
std::condition_variable | cv_ |
Allows blocking actors to actively wait for incoming messages. | |
error | fail_state_ |
Stores the user-defined exit reason if this actor has finished execution. | |
attachable_ptr | attachables_head_ |
Points to the first attachable in the linked list of attachables (if any). | |
Protected Attributes inherited from caf::io::basp::instance::callee | |
proxy_registry | namespace_ |
Related Functions inherited from caf::scheduled_actor | |
CAF_CORE_EXPORT skippable_result | reflect (scheduled_actor *, message &) |
CAF_CORE_EXPORT skippable_result | reflect_and_quit (scheduled_actor *, message &) |
CAF_CORE_EXPORT skippable_result | print_and_drop (scheduled_actor *, message &) |
CAF_CORE_EXPORT skippable_result | drop (scheduled_actor *, message &) |
Related Functions inherited from caf::local_actor | |
constexpr keep_behavior_t | keep_behavior = keep_behavior_t{} |
Policy tag that causes event_based_actor::become to keep the current behavior available. | |
Related Functions inherited from caf::abstract_actor | |
using | actor_id = uint64_t |
A unique actor ID. | |
Related Functions inherited from caf::flow::coordinator | |
using | coordinator_ptr = intrusive_ptr< coordinator > |
Related Functions inherited from caf::async::execution_context | |
using | execution_context_ptr = intrusive_ptr< execution_context > |
void | intrusive_ptr_add_ref (const execution_context *ptr) noexcept |
void | intrusive_ptr_release (const execution_context *ptr) noexcept |
A broker implementation for the Binary Actor System Protocol (BASP).
|
overridevirtual |
Called if a server handshake was received and the connection to nid
is established.
Implements caf::io::basp::instance::callee.
|
overridevirtual |
Called whenever BASP learns the ID of a remote node to which it does not have a direct connection.
Implements caf::io::basp::instance::callee.
|
overridevirtual |
Called whenever BASP learns the ID of a remote node to which it does not have a direct connection.
Implements caf::io::basp::instance::callee.
|
overridevirtual |
Returns an implementation-dependent name for logging purposes, which is only valid as long as the actor is running.
The default implementation simply returns "actor".
Reimplemented from caf::io::abstract_broker.
|
overridevirtual |
Can be overridden to perform cleanup code after an actor finished execution.
Reimplemented from caf::local_actor.
Called whenever a remote node created a proxy for one of our local actors.
Implements caf::io::basp::instance::callee.
|
overridevirtual |
Returns a factory for proxies created and managed by this actor or nullptr
.
Reimplemented from caf::scheduled_actor.
|
overridevirtual |
Called whenever a direct connection was closed or a node became unreachable for other reasons before this node gets erased from the routing table.
Implements caf::io::basp::instance::callee.
|
overridevirtual |
Resume any pending computation until it is either finished or needs to be re-scheduled later.
Reimplemented from caf::io::abstract_broker.
void caf::io::basp_broker::set_context | ( | connection_handle | hdl | ) |
bool caf::io::basp_broker::automatic_connections = false |
Configures whether BASP automatically open new connections to optimize routing paths by forming a mesh between all nodes.
std::unordered_map<node_id, std::vector<actor_addr> > caf::io::basp_broker::node_observers |
Keeps track of actors that wish to receive a node_down_msg
if a particular node fails.
Stores handles to spawn servers for other nodes.
These servers are spawned whenever the broker learns a new node ID and tries to get a 'SpawnServ' instance on the remote side.