libcaf
0.13.2
|
Base class for strongly typed actors using a functor-based implementation. More...
#include <spawn.hpp>
Public Types | |
using | base = typed_event_based_actor< Sigs...> |
Base class for actors using given interface. | |
using | pointer = base * |
Pointer to the base class. | |
using | behavior_type = typename base::behavior_type |
Behavior with proper type information. | |
using | no_arg_fun = std::function< behavior_type()> |
First valid functor signature. | |
using | one_arg_fun1 = std::function< behavior_type(pointer)> |
Second valid functor signature. | |
using | one_arg_fun2 = std::function< void(pointer)> |
Third (and last) valid functor signature. | |
![]() | |
using | base_type = abstract_event_based_actor< typed_behavior< Sigs...>, true > |
using | signatures = detail::type_list< Sigs...> |
using | behavior_type = typed_behavior< Sigs...> |
![]() | |
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 F , class... Ts> | |
functor_based_typed_actor (F fun, Ts &&...xs) | |
Creates a new instance from given functor, binding xs... to the functor. | |
![]() | |
std::set< std::string > | message_types () const override |
Returns the set of accepted messages types as strings or an empty set if this actor is untyped. | |
void | initialize () override |
void | send (message_priority mp, const typed_actor< Sigs...> &dest, Ts &&...xs) |
void | send (const typed_actor< DestSigs...> &dest, Ts &&...xs) |
void | delayed_send (message_priority mp, const typed_actor< Sigs...> &dest, const duration &rtime, Ts &&...xs) |
void | delayed_send (const typed_actor< Sigs...> &dest, const duration &rtime, Ts &&...xs) |
![]() | |
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, class... Ts> | |
actor | spawn_in_group (const group &grp, 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 . | |
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. | |
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. | |
![]() | |
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. | |
bool | remove_backlink (const actor_addr &other) |
Removes the link relation between this actor and other and returns whether the operation succeeded. | |
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. | |
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. | |
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 | |
behavior_type | make_behavior () override |
![]() | |
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 > | m_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) |
Base class for strongly typed actors using a functor-based implementation.