libcaf  0.15.3
Classes | Public Types | Public Member Functions | Friends | List of all members
caf::actor_system Class Reference

Actor environment including scheduler, registry, and optional components such as a middleman. More...

#include <actor_system.hpp>

Classes

class  module
 An (optional) component of the actor system. More...
 

Public Types

using module_ptr = std::unique_ptr< module >
 
using module_array = std::array< module_ptr, module::num_ids >
 
using named_actor_config_map = std::unordered_map< std::string, named_actor_config >
 
using mpi = std::set< std::string >
 A message passing interface (MPI) in run-time checkable representation.
 

Public Member Functions

 actor_system (const actor_system &)=delete
 
actor_systemoperator= (const actor_system &)=delete
 
 actor_system (actor_system_config &cfg)
 
mpi message_types (detail::type_list< scoped_actor >) const
 
mpi message_types (detail::type_list< actor >) const
 
mpi message_types (detail::type_list< strong_actor_ptr >) const
 
template<class... Ts>
mpi message_types (detail::type_list< typed_actor< Ts... >>) const
 
mpi message_types (const actor &) const
 
template<class... Ts>
mpi message_types (const typed_actor< Ts... > &) const
 
template<class T >
mpi message_types () const
 Returns a string representation of the messaging interface using portable names;.
 
bool assignable (const mpi &xs, const mpi &ys) const
 Returns whether actor handles described by xs can be assigned to actor handles described by ys. More...
 
template<class T >
bool assignable (const std::set< std::string > &xs) const
 Returns whether actor handles described by xs can be assigned to actor handles of type T. More...
 
const node_idnode () const
 Returns the host-local identifier for this system.
 
scheduler::abstract_coordinatorscheduler ()
 Returns the scheduler instance.
 
caf::loggerlogger ()
 Returns the system-wide event logger.
 
actor_registryregistry ()
 Returns the system-wide actor registry.
 
const uniform_type_info_map & types () const
 Returns the system-wide factory for custom types and actors.
 
std::string render (const error &x) const
 Returns a string representation for err.
 
group_manager & groups ()
 Returns the system-wide group manager.
 
bool has_middleman () const
 Returns true if the I/O module is available, false otherwise.
 
io::middlemanmiddleman ()
 Returns the middleman instance from the I/O module. More...
 
opencl::manager & opencl_manager () const
 Returns the opencl manager instance from opencl module. More...
 
bool has_opencl_manager () const
 Returns true if the opencl module is available, false otherwise.
 
scoped_execution_unitdummy_execution_unit ()
 Returns a dummy execution unit that forwards everything to the scheduler. More...
 
actor_id next_actor_id ()
 Returns a new actor ID.
 
actor_id latest_actor_id () const
 Returns the last given actor ID.
 
void await_all_actors_done () const
 Blocks this caller until all actors are done.
 
template<class C , spawn_options Os, class... Ts>
infer_handle_from_class_t< C > spawn_class (actor_config &cfg, Ts &&...xs)
 Called by spawn when used to create a class-based actor to apply automatic conversions to xs before spawning the actor. More...
 
template<class C , spawn_options Os = no_spawn_options, class... Ts>
infer_handle_from_class_t< C > spawn (Ts &&...xs)
 Returns a new actor of type C using xs... as constructor arguments. More...
 
template<class S , spawn_options Os = no_spawn_options>
infer_handle_from_state_t< S > spawn ()
 
template<spawn_options Os, class C , class F , class... Ts>
infer_handle_from_class_t< C > spawn_functor_impl (actor_config &cfg, F &fun, Ts &&...xs)
 Called by spawn_functor to apply static assertions and store an initialization function in cfg before calling spawn_class. More...
 
template<spawn_options Os = no_spawn_options, class F , class... Ts>
infer_handle_from_fun_t< F > spawn_functor (actor_config &cfg, F &fun, Ts &&...xs)
 Called by spawn when used to create a functor-based actor to select a proper implementation and then delegates to spawn_functor_impl. More...
 
template<spawn_options Os = no_spawn_options, class F , class... Ts>
infer_handle_from_fun_t< F > spawn (F fun, Ts &&...xs)
 Returns a new functor-based actor. More...
 
template<class Handle , class E = typename std::enable_if<is_handle<Handle>::value>::type>
expected< Handle > spawn (const std::string &name, message args, execution_unit *ctx=nullptr, bool check_interface=true, const mpi *expected_ifs=nullptr)
 Returns a new actor with run-time type name, constructed with the arguments stored in args. More...
 
template<spawn_options Os = no_spawn_options, class F , class... Ts>
infer_handle_from_fun_t< F > spawn_in_groups (std::initializer_list< group > gs, F fun, Ts &&...xs)
 Returns a new functor-based actor subscribed to all groups in gs.
 
template<spawn_options Os = no_spawn_options, class Gs , class F , class... Ts>
infer_handle_from_fun_t< F > spawn_in_groups (const Gs &gs, F fun, Ts &&...xs)
 Returns a new functor-based actor subscribed to all groups in gs.
 
template<spawn_options Os = no_spawn_options, class F , class... Ts>
infer_handle_from_fun_t< F > spawn_in_group (const group &grp, F fun, Ts &&...xs)
 Returns a new functor-based actor subscribed to all groups in gs.
 
template<class T , spawn_options Os = no_spawn_options, class... Ts>
infer_handle_from_class_t< T > spawn_in_groups (std::initializer_list< group > gs, Ts &&...xs)
 Returns a new class-based actor subscribed to all groups in gs.
 
template<class T , spawn_options Os = no_spawn_options, class Gs , class... Ts>
infer_handle_from_class_t< T > spawn_in_groups (const Gs &gs, Ts &&...xs)
 Returns a new class-based actor subscribed to all groups in gs.
 
template<class T , spawn_options Os = no_spawn_options, class... Ts>
infer_handle_from_class_t< T > spawn_in_group (const group &grp, Ts &&...xs)
 Returns a new class-based actor subscribed to all groups in gs.
 
bool await_actors_before_shutdown () const
 Returns whether this actor system calls await_all_actors_done in its destructor before shutting down. More...
 
void await_actors_before_shutdown (bool x)
 Configures whether this actor system calls await_all_actors_done in its destructor before shutting down. More...
 
const actor_system_configconfig () const
 Returns the configuration of this actor system.
 
const named_actor_config_map & named_actor_configs () const
 Returns configuration parameters for individual named actors types.
 

Friends

class logger
 
class io::middleman
 
class abstract_actor
 

Detailed Description

Actor environment including scheduler, registry, and optional components such as a middleman.

Examples:
dancing_kirby.cpp, dining_philosophers.cpp, and hello_world.cpp.

Constructor & Destructor Documentation

caf::actor_system::actor_system ( actor_system_config cfg)
explicit
Warning
The system stores a reference to cfg, which means the config object must outlive the actor system.

Member Function Documentation

bool caf::actor_system::assignable ( const mpi xs,
const mpi ys 
) const

Returns whether actor handles described by xs can be assigned to actor handles described by ys.

Attention
This feature is experimental.
template<class T >
bool caf::actor_system::assignable ( const std::set< std::string > &  xs) const

Returns whether actor handles described by xs can be assigned to actor handles of type T.

Attention
This feature is experimental.
bool caf::actor_system::await_actors_before_shutdown ( ) const

Returns whether this actor system calls await_all_actors_done in its destructor before shutting down.

void caf::actor_system::await_actors_before_shutdown ( bool  x)

Configures whether this actor system calls await_all_actors_done in its destructor before shutting down.

scoped_execution_unit* caf::actor_system::dummy_execution_unit ( )

Returns a dummy execution unit that forwards everything to the scheduler.

io::middleman& caf::actor_system::middleman ( )

Returns the middleman instance from the I/O module.

Exceptions
<tt>std::logic_error</tt>if module is not loaded.
opencl::manager& caf::actor_system::opencl_manager ( ) const

Returns the opencl manager instance from opencl module.

Exceptions
<tt>std::logic_error</tt>if module is not loaded.
template<class C , spawn_options Os = no_spawn_options, class... Ts>
infer_handle_from_class_t<C> caf::actor_system::spawn ( Ts &&...  xs)

Returns a new actor of type C using xs... as constructor arguments.

The behavior of spawn can be modified by setting Os, e.g., to opt-out of the cooperative scheduling.

Parameters
xsConstructor arguments for C.
Examples:
dancing_kirby.cpp.
template<spawn_options Os = no_spawn_options, class F , class... Ts>
infer_handle_from_fun_t<F> caf::actor_system::spawn ( fun,
Ts &&...  xs 
)

Returns a new functor-based actor.

The first argument must be the functor, the remainder of xs... is used to invoke the functor. The behavior of spawn can be modified by setting Os, e.g., to opt-out of the cooperative scheduling.

template<class Handle , class E = typename std::enable_if<is_handle<Handle>::value>::type>
expected<Handle> caf::actor_system::spawn ( const std::string &  name,
message  args,
execution_unit ctx = nullptr,
bool  check_interface = true,
const mpi expected_ifs = nullptr 
)

Returns a new actor with run-time type name, constructed with the arguments stored in args.

Attention
This feature is experimental.
template<class C , spawn_options Os, class... Ts>
infer_handle_from_class_t<C> caf::actor_system::spawn_class ( actor_config cfg,
Ts &&...  xs 
)

Called by spawn when used to create a class-based actor to apply automatic conversions to xs before spawning the actor.

Should not be called by users of the library directly.

Parameters
cfgTo-be-filled config for the actor.
xsConstructor arguments for C.
template<spawn_options Os = no_spawn_options, class F , class... Ts>
infer_handle_from_fun_t<F> caf::actor_system::spawn_functor ( actor_config cfg,
F &  fun,
Ts &&...  xs 
)

Called by spawn when used to create a functor-based actor to select a proper implementation and then delegates to spawn_functor_impl.

Should not be called by users of the library directly.

Parameters
cfgTo-be-filled config for the actor.
funFunction object for the actor's behavior; will be moved.
xsArguments for fun.
template<spawn_options Os, class C , class F , class... Ts>
infer_handle_from_class_t<C> caf::actor_system::spawn_functor_impl ( actor_config cfg,
F &  fun,
Ts &&...  xs 
)

Called by spawn_functor to apply static assertions and store an initialization function in cfg before calling spawn_class.

Parameters
cfgTo-be-filled config for the actor.
funFunction object for the actor's behavior; will be moved.
xsArguments for fun.

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