libcaf  0.15.3
Public Types | Public Member Functions | List of all members
caf::actor_companion Class Reference

An co-existing actor forwarding all messages through a user-defined callback to another object, thus serving as gateway to allow any object to interact with other actors. More...

#include <actor_companion.hpp>

Inherits local_actor, and with< mixin::sender, mixin::subscriber, mixin::behavior_changer >.

Public Types

using signatures = none_t
 Required by spawn for type deduction.
 
using behavior_type = behavior
 Required by spawn for type deduction.
 
using lock_type = detail::shared_spinlock
 A shared lockable.
 
using enqueue_handler = std::function< void(mailbox_element_ptr)>
 Delegates incoming messages to user-defined event loop.
 
using on_exit_handler = std::function< void()>
 Callback for actor termination.
 

Public Member Functions

 actor_companion (actor_config &cfg)
 
void enqueue (mailbox_element_ptr ptr, execution_unit *host) override
 
void enqueue (strong_actor_ptr src, message_id mid, message content, execution_unit *eu) override
 
void launch (execution_unit *eu, bool lazy, bool hide) override
 
void on_exit () override
 
void disconnect (exit_reason rsn=exit_reason::normal)
 Removes the handler for incoming messages and terminates the companion for exit reason rsn. More...
 
void on_enqueue (enqueue_handler handler)
 Sets the handler for incoming messages. More...
 
void on_exit (on_exit_handler handler)
 Sets the handler for incoming messages.
 

Detailed Description

An co-existing actor forwarding all messages through a user-defined callback to another object, thus serving as gateway to allow any object to interact with other actors.

Member Function Documentation

void caf::actor_companion::disconnect ( exit_reason  rsn = exit_reason::normal)

Removes the handler for incoming messages and terminates the companion for exit reason rsn.

void caf::actor_companion::on_enqueue ( enqueue_handler  handler)

Sets the handler for incoming messages.

Warning
handler needs to be thread-safe

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