C++ Actor Framework 0.18
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | List of all members
caf::decorator::sequencer Class Reference

An actor decorator implementing "dot operator"-like compositions, i.e., f.g(x) = f(g(x)). More...

#include <sequencer.hpp>

Inheritance diagram for caf::decorator::sequencer:
caf::monitorable_actor caf::abstract_actor caf::abstract_channel

Public Types

using message_types_set = std::set< std::string >
 

Public Member Functions

 sequencer (strong_actor_ptr f, strong_actor_ptr g, message_types_set msg_types)
 
bool enqueue (mailbox_element_ptr what, execution_unit *context) override
 Enqueues a new message wrapped in a mailbox_element to the actor.
 
message_types_set message_types () const override
 Returns the set of accepted messages types as strings or an empty set if this actor is untyped.
 
void setup_metrics ()
 
- Public Member Functions inherited from caf::monitorable_actor
virtual const char * name () const
 Returns an implementation-dependent name for logging purposes, which is only valid as long as the actor is running.
 
void attach (attachable_ptr ptr) override
 Attaches ptr to this actor.
 
size_t detach (const attachable::token &what) override
 Detaches the first attached object that matches what.
 
void link_to (const actor_addr &x)
 Links this actor to x.
 
template<class ActorHandle >
void link_to (const ActorHandle &x)
 Links this actor to x.
 
void unlink_from (const actor_addr &x)
 Unlinks this actor from x.
 
template<class ActorHandle >
void unlink_from (const ActorHandle &x)
 Links this actor to x.
 
- Public Member Functions inherited from caf::abstract_actor
actor_control_blockctrl () const
 
 abstract_actor (const abstract_actor &)=delete
 
abstract_actoroperator= (const abstract_actor &)=delete
 
virtual void on_destroy ()
 Cleans up any remaining state before the destructor is called.
 
bool enqueue (strong_actor_ptr sender, message_id mid, message msg, execution_unit *host) override
 Enqueues a new message without forwarding stack to the channel.
 
virtual bool enqueue (mailbox_element_ptr what, execution_unit *host)=0
 Enqueues a new message wrapped in a mailbox_element to the actor.
 
virtual void attach (attachable_ptr ptr)=0
 Attaches ptr to this actor.
 
template<class F >
void attach_functor (F f)
 Convenience function that attaches the functor f to this actor.
 
actor_addr address () const noexcept
 Returns the logical actor address.
 
virtual size_t detach (const attachable::token &what)=0
 Detaches the first attached object that matches what.
 
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.
 
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_systemhome_system () const noexcept
 Returns the system that created this actor (or proxy).
 
- Public Member Functions inherited from caf::abstract_channel
virtual bool enqueue (strong_actor_ptr sender, message_id mid, message content, execution_unit *host=nullptr)=0
 Enqueues a new message without forwarding stack to the channel.
 
bool is_abstract_actor () const
 
bool is_abstract_group () const
 
bool is_actor_decorator () const
 

Protected Member Functions

void on_cleanup (const error &reason) override
 Allows subclasses to add additional cleanup code to the critical section in cleanup.
 
- Protected Member Functions inherited from caf::monitorable_actor
virtual void on_cleanup (const error &reason)
 Allows subclasses to add additional cleanup code to the critical section in cleanup.
 
void bounce (mailbox_element_ptr &what)
 Sends a response message if what is a request.
 
void bounce (mailbox_element_ptr &what, const error &err)
 Sends a response message if what is a request.
 
 monitorable_actor (actor_config &cfg)
 Creates a new actor instance.
 
void attach_impl (attachable_ptr &ptr)
 
size_t detach_impl (const attachable::token &what, bool stop_on_hit=false, bool dry_run=false)
 
bool handle_system_message (mailbox_element &x, execution_unit *ctx, bool trap_exit)
 
template<class F >
bool handle_system_message (mailbox_element &x, execution_unit *context, bool trap_exit, F &down_msg_handler)
 
- Protected Member Functions inherited from caf::abstract_actor
 abstract_actor (actor_config &cfg)
 
- Protected Member Functions inherited from caf::abstract_channel
int flags () const
 
void flags (int new_value)
 

Additional Inherited Members

- Static Public Attributes inherited from caf::abstract_channel
static constexpr int is_abstract_actor_flag = 0x01000000
 
static constexpr int is_abstract_group_flag = 0x02000000
 
static constexpr int is_actor_bind_decorator_flag = 0x04000000
 
static constexpr int is_actor_dot_decorator_flag = 0x08000000
 
static constexpr int is_actor_decorator_mask = 0x0C000000
 
static constexpr int is_hidden_flag = 0x10000000
 
- Protected Attributes inherited from caf::monitorable_actor
error fail_state_
 
std::condition_variable cv_
 
attachable_ptr attachables_head_
 
- Protected Attributes inherited from caf::abstract_actor
std::mutex mtx_
 

Detailed Description

An actor decorator implementing "dot operator"-like compositions, i.e., f.g(x) = f(g(x)).

Composed actors are hidden actors. A composed actor exits when either of its constituent actors exits; Constituent actors have no dependency on the composed actor by default, and exit of a composed actor has no effect on its constituent actors. A composed actor is hosted on the same actor system and node as g, the first actor on the forwarding chain.

Member Function Documentation

◆ enqueue()

bool caf::decorator::sequencer::enqueue ( mailbox_element_ptr  what,
execution_unit host 
)
overridevirtual

Enqueues a new message wrapped in a mailbox_element to the actor.

This enqueue variant allows to define forwarding chains.

Returns
true if the message has added to the mailbox, false otherwise. In the latter case, the actor terminated and the message has been dropped. Once this function returns false, it returns false for all future invocations.
Note
The returned value is purely informational and may be used to discard actor handles early. Messages may still get dropped later even if this function returns true. In particular when dealing with remote actors.

Implements caf::abstract_actor.

◆ message_types()

message_types_set caf::decorator::sequencer::message_types ( ) const
overridevirtual

Returns the set of accepted messages types as strings or an empty set if this actor is untyped.

Reimplemented from caf::abstract_actor.

◆ on_cleanup()

void caf::decorator::sequencer::on_cleanup ( const error reason)
overrideprotectedvirtual

Allows subclasses to add additional cleanup code to the critical section in cleanup.

This member function is called inside of a critical section.

Reimplemented from caf::monitorable_actor.


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