libcaf
0.13.2
|
A thread-mapped or context-switching actor using a blocking receive rather than a behavior-stack based message processing. More...
#include <blocking_actor.hpp>
Public Types | |
using | timeout_type = std::chrono::high_resolution_clock::time_point |
![]() | |
using | mailbox_type = detail::single_reader_queue< mailbox_element, detail::disposer > |
![]() | |
enum | resume_result { resume_later, awaiting_message, done, shutdown_execution_unit } |
Public Member Functions | |
template<class... Ts> | |
void | receive (Ts &&...xs) |
Dequeues the next message from the mailbox that is matched by given behavior. More... | |
template<class... Ts> | |
void | receive_loop (Ts &&...xs) |
Semantically equal to: for (;;) { receive(...); } , but does not cause a temporary behavior object per iteration. More... | |
template<class T > | |
receive_for_helper< T > | receive_for (T &begin, const T &end) |
Receives messages for range [begin, first) . More... | |
template<class Statement > | |
receive_while_helper | receive_while (Statement stmt) |
Receives messages as long as stmt returns true. More... | |
template<class... Ts> | |
do_receive_helper | do_receive (Ts &&...xs) |
Receives messages until stmt returns true. More... | |
void | await_all_other_actors_done () |
Blocks this actor until all other actors are done. | |
virtual void | act () |
Implements the actor's behavior. | |
![]() | |
template<class T , spawn_options Os = no_spawn_options, class... Ts> | |
actor | spawn (Ts &&...xs) |
template<spawn_options Os = no_spawn_options, class... Ts> | |
actor | spawn (Ts &&...xs) |
template<class T , spawn_options Os = no_spawn_options, class Groups , class... Ts> | |
actor | spawn_in_groups (const Groups &grps, Ts &&...xs) |
template<class T , spawn_options Os = no_spawn_options, class... Ts> | |
actor | spawn_in_groups (std::initializer_list< group > grps, Ts &&...xs) |
template<class T , spawn_options Os = no_spawn_options, class... Ts> | |
actor | spawn_in_group (const group &grp, Ts &&...xs) |
template<spawn_options Os = no_spawn_options, class Groups , class... Ts> | |
actor | spawn_in_groups (const Groups &grps, Ts &&...xs) |
template<spawn_options Os = no_spawn_options, class... Ts> | |
actor | spawn_in_groups (std::initializer_list< group > grps, Ts &&...xs) |
template<spawn_options Os = no_spawn_options, class... Ts> | |
actor | spawn_in_group (const group &grp, Ts &&...xs) |
template<class T , spawn_options Os = no_spawn_options, class... Ts> | |
actor_handle_from_signature_list< typename T::signatures >::type | spawn_typed (Ts &&...xs) |
template<spawn_options Os = no_spawn_options, typename F , class... Ts> | |
infer_typed_actor_handle< typename detail::get_callable_trait< F >::result_type, typename detail::tl_head< typename detail::get_callable_trait< F >::arg_types >::type >::type | spawn_typed (F fun, Ts &&...xs) |
template<class... Ts> | |
void | send (message_priority mp, const channel &dest, Ts &&...xs) |
Sends {xs...} to dest using the priority mp . | |
template<class... Ts> | |
void | send (const channel &dest, Ts &&...xs) |
Sends {xs...} to dest using normal priority. | |
template<class... Sigs, class... Ts> | |
void | send (message_priority mp, const typed_actor< Sigs...> &dest, Ts &&...xs) |
Sends {xs...} to dest using the priority mp . | |
template<class... Sigs, class... Ts> | |
void | send (const typed_actor< Sigs...> &dest, Ts &&...xs) |
Sends {xs...} to dest using normal priority. | |
void | send_exit (const actor_addr &dest, uint32_t reason) |
Sends an exit message to dest . | |
template<class ActorHandle > | |
void | send_exit (const ActorHandle &dest, uint32_t reason) |
Sends an exit message to dest . | |
template<class... Ts> | |
void | delayed_send (message_priority mp, const channel &dest, const duration &rtime, Ts &&...xs) |
Sends a message to dest that is delayed by rel_time using the priority mp . More... | |
template<class... Ts> | |
void | delayed_send (const channel &dest, const duration &rtime, Ts &&...xs) |
Sends a message to dest that is delayed by rel_time . | |
template<class... Sigs, class... Ts> | |
void | delayed_send (message_priority mp, const typed_actor< Sigs...> &dest, const duration &rtime, Ts &&...xs) |
Sends {xs...} delayed by rtime to dest using the priority mp . | |
template<class... Sigs, class... Ts> | |
void | delayed_send (const typed_actor< Sigs...> &dest, const duration &rtime, Ts &&...xs) |
Sends {xs...} delayed by rtime to dest using the priority mp . | |
void | join (const group &what) |
Causes this actor to subscribe to the group what . More... | |
void | leave (const group &what) |
Causes this actor to leave the group what . | |
void | quit (uint32_t reason=exit_reason::normal) |
Finishes execution of this actor after any currently running message handler is done. More... | |
bool | trap_exit () const |
Checks whether this actor traps exit messages. | |
void | trap_exit (bool value) |
Enables or disables trapping of exit messages. | |
message & | current_message () |
Returns the currently processed message. More... | |
actor_addr & | current_sender () |
Returns the address of the sender of the current message. More... | |
void | monitor (const actor_addr &whom) |
Adds a unidirectional monitor to whom . More... | |
void | monitor (const actor &whom) |
Adds a unidirectional monitor to whom . More... | |
template<class... Ts> | |
void | monitor (const typed_actor< Ts...> &whom) |
Adds a unidirectional monitor to whom . More... | |
void | demonitor (const actor_addr &whom) |
Removes a monitor from whom . | |
void | demonitor (const actor &whom) |
Removes a monitor from whom . | |
virtual void | on_exit () |
Can be overridden to perform cleanup code after an actor finished execution. More... | |
std::vector< group > | joined_groups () const |
Returns all joined groups. | |
response_promise | make_response_promise () |
Creates a response_promise to response to a request later on. | |
void | on_sync_failure (std::function< void()> fun) |
Sets the handler for unexpected synchronous response messages. | |
bool | has_sync_failure_handler () |
Checks wheter this actor has a user-defined sync failure handler. | |
template<class F > | |
void | set_exception_handler (F f) |
Sets a custom exception handler for this actor. More... | |
message & | last_dequeued () CAF_DEPRECATED |
actor_addr & | last_sender () CAF_DEPRECATED |
void | send_tuple (message_priority mp, const channel &whom, message what) CAF_DEPRECATED |
void | send_tuple (const channel &whom, message what) CAF_DEPRECATED |
void | delayed_send_tuple (message_priority mp, const channel &whom, const duration &rtime, message data) CAF_DEPRECATED |
void | delayed_send_tuple (const channel &whom, const duration &rtime, message data) CAF_DEPRECATED |
void | attach_to_scheduler () override |
Initializes this object, e.g., by increasing the the reference count. | |
void | detach_from_scheduler () override |
Uninitializes this object, e.g., by decrementing the the reference count. | |
resumable::resume_result | resume (execution_unit *, size_t) override |
Resume any pending computation until it is either finished or needs to be re-scheduled later. More... | |
![]() | |
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... | |
actor_addr | address () const |
Returns the logical actor address. | |
size_t | detach (const attachable::token &what) |
Detaches the first attached object that matches what . | |
void | link_to (const actor_addr &whom) |
Links this actor to whom . | |
template<class ActorHandle > | |
void | link_to (const ActorHandle &whom) |
Links this actor to whom . | |
void | unlink_from (const actor_addr &other) |
Unlinks this actor from whom . | |
template<class ActorHandle > | |
void | unlink_from (const ActorHandle &other) |
Unlinks this actor from whom . | |
bool | establish_backlink (const actor_addr &other) |
Establishes a link relation between this actor and other and returns whether the operation succeeded. More... | |
bool | remove_backlink (const actor_addr &other) |
Removes the link relation between this actor and other and returns whether the operation succeeded. More... | |
uint32_t | id () const |
Returns the unique ID of this actor. | |
uint32_t | exit_reason () const |
Returns the actor's exit reason or exit_reason::not_exited if it's still alive. More... | |
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... | |
execution_unit * | host () const |
Returns the execution unit currently used by this actor. More... | |
void | host (execution_unit *new_host) |
Sets the execution unit for this actor. | |
![]() | |
virtual void | enqueue (const actor_addr &sender, message_id mid, message content, execution_unit *host)=0 |
Enqueues a new message to the channel. | |
virtual void | enqueue (mailbox_element_ptr what, execution_unit *host) |
Enqueues a new message wrapped in a mailbox_element to the channel. More... | |
node_id | node () const |
Returns the ID of the node this actor is running on. | |
bool | is_remote () const |
Returns true if node_ptr returns. | |
bool | is_abstract_actor () const |
bool | is_abstract_group () const |
![]() | |
ref_counted (const ref_counted &) | |
ref_counted & | operator= (const ref_counted &) |
void | ref () noexcept |
Increases reference count by one. | |
void | deref () noexcept |
Decreases reference count by one and calls request_deletion when it drops to zero. More... | |
bool | unique () const noexcept |
Queries whether there is exactly one reference. | |
size_t | get_reference_count () const noexcept |
![]() | |
virtual void | request_deletion (bool decremented_rc) noexcept |
Default implementations calls `delete this, but can be overriden in case deletion depends on some condition or the class doesn't use default new/delete. More... | |
Protected Member Functions | |
std::function< void(behavior &)> | make_dequeue_callback () |
![]() | |
abstract_actor () | |
Creates a non-proxy instance. | |
abstract_actor (actor_id aid, node_id nid) | |
Creates a proxy instance for a proxy running on nid . | |
void | cleanup (uint32_t reason) |
Called by the runtime system to perform cleanup actions for this actor. More... | |
bool | exited () const |
Returns exit_reason() != exit_reason::not_exited . | |
![]() | |
int | flags () const |
void | flags (int new_value) |
Additional Inherited Members | |
![]() | |
static constexpr auto | memory_cache_flag = detail::needs_embedding |
![]() | |
static constexpr int | is_abstract_actor_flag = 0x100000 |
static constexpr int | is_abstract_group_flag = 0x200000 |
![]() | |
std::atomic< size_t > | rc_ |
![]() | |
using | local_actor_ptr = intrusive_ptr< local_actor > |
A smart pointer to a local_actor instance. | |
constexpr keep_behavior_t | keep_behavior = keep_behavior_t{} |
Policy tag that causes event_based_actor::become to keep the current behavior available. | |
![]() | |
using | actor_id = uint32_t |
A unique actor ID. | |
![]() | |
void | intrusive_ptr_add_ref (ref_counted *p) |
void | intrusive_ptr_release (ref_counted *p) |
A thread-mapped or context-switching actor using a blocking receive rather than a behavior-stack based message processing.
do_receive_helper caf::blocking_actor::do_receive | ( | Ts &&... | xs | ) |
Receives messages until stmt
returns true.
Semantically equal to: do { receive(...); } while (stmt() == false);
Usage example:
void caf::blocking_actor::receive | ( | Ts &&... | xs | ) |
Dequeues the next message from the mailbox that is matched by given behavior.
receive_for_helper<T> caf::blocking_actor::receive_for | ( | T & | begin, |
const T & | end | ||
) |
Receives messages for range [begin, first)
.
Semantically equal to: for ( ; begin != end; ++begin) { receive(...); }
.
Usage example:
void caf::blocking_actor::receive_loop | ( | Ts &&... | xs | ) |
Semantically equal to: for (;;) { receive(...); }
, but does not cause a temporary behavior object per iteration.
receive_while_helper caf::blocking_actor::receive_while | ( | Statement | stmt | ) |
Receives messages as long as stmt
returns true.
Semantically equal to: while (stmt()) { receive(...); }
.
Usage example: