20#pragma warning(disable : 4251)
26using plugins_t = std::deque<plugin::plugin_base_t *>;
49 PluginList plugin_list;
51 template <
size_t Index = 0>
void add_plugin(
plugins_t &plugins)
noexcept {
52 plugins.emplace_back(&std::get<Index>(plugin_list));
53 if constexpr (Index + 1 < std::tuple_size_v<PluginList>) {
54 add_plugin<Index + 1>(plugins);
82 bool escalate_failure =
false;
85 bool autoshutdown_supervisor =
false;
94 using builder_t =
typename Actor::template config_builder_t<Actor>;
110 constexpr static const std::uint32_t INIT_TIMEOUT = 1 << 0;
113 constexpr static const std::uint32_t SHUTDOWN_TIMEOUT = 1 << 1;
116 constexpr static const std::uint32_t requirements_mask = INIT_TIMEOUT | SHUTDOWN_TIMEOUT;
131 std::uint32_t mask = builder_t::requirements_mask;
138 : install_action{std::move(action_)}, supervisor{nullptr}, system_context{system_context_}, config{nullptr} {
144 config.init_timeout = config.shutdown_timeout = timeout;
145 mask = (mask & (~INIT_TIMEOUT & ~SHUTDOWN_TIMEOUT));
146 return std::move(*
static_cast<builder_t *
>(
this));
151 config.init_timeout = timeout;
152 mask = (mask & ~INIT_TIMEOUT);
153 return std::move(*
static_cast<builder_t *
>(
this));
158 config.shutdown_timeout = timeout;
159 mask = (mask & ~SHUTDOWN_TIMEOUT);
160 return std::move(*
static_cast<builder_t *
>(
this));
169 config.spawner_address = value;
170 return std::move(*
static_cast<builder_t *
>(
this));
182 config.escalate_failure = value;
183 return std::move(*
static_cast<builder_t *
>(
this));
192 config.autoshutdown_supervisor = value;
193 return std::move(*
static_cast<builder_t *
>(
this));
197 virtual bool validate() noexcept {
return mask ? false :
true; }
205 void init_ctor() noexcept {
207 using plugins_list_t =
typename Actor::plugins_list_t;
209 return std::make_unique<storage_t>();
Basic namespace for all rotor functionalities.
Definition rotor.hpp:21
intrusive_ptr_t< address_t > address_ptr_t
intrusive pointer for address
Definition address.hpp:57
std::unique_ptr< plugin_storage_base_t > plugin_storage_ptr_t
smart pointer for plugin_storage_base_t
Definition actor_config.h:38
intrusive_ptr_t< actor_base_t > actor_ptr_t
intrusive pointer for actor
Definition forward.hpp:23
std::deque< plugin::plugin_base_t * > plugins_t
list of raw plugin pointers
Definition actor_config.h:26
boost::intrusive_ptr< T > intrusive_ptr_t
alias for intrusive pointer
Definition arc.hpp:27
CRTP actor config builder.
Definition actor_config.h:92
builder_t && autoshutdown_supervisor(bool value=true) &&noexcept
shutdown supervisor when an actor is down
Definition actor_config.h:191
builder_t && init_timeout(const pt::time_duration &timeout) &&noexcept
setter for init timeout
Definition actor_config.h:150
builder_t && escalate_failure(bool value=true) &&noexcept
shutdown supervisor upon actor failure
Definition actor_config.h:181
typename Actor::config_t config_t
final config class
Definition actor_config.h:97
system_context_t & system_context
reference to system_context_t
Definition actor_config.h:125
virtual bool validate() noexcept
checks whether config is valid, i.e. all necessary fields are set
Definition actor_config.h:197
builder_t && spawner_address(const address_ptr_t &value) &&noexcept
spawner address
Definition actor_config.h:168
builder_t && shutdown_timeout(const pt::time_duration &timeout) &&noexcept
setter for shutdown timeout
Definition actor_config.h:157
config_t config
the currently build config
Definition actor_config.h:128
builder_t && timeout(const pt::time_duration &timeout) &&noexcept
setter for init and shutdown timeout
Definition actor_config.h:143
typename Actor::template config_builder_t< Actor > builder_t
final builder class
Definition actor_config.h:94
intrusive_ptr_t< Actor > actor_ptr_t
intrusive pointer to actor
Definition actor_config.h:100
actor_config_builder_t(install_action_t &&action_, system_context_t &system_context_)
ctor with install action and pointer to system_context_t
Definition actor_config.h:137
supervisor_t * supervisor
raw pointer to supervisor_t (is null for top-level supervisors)
Definition actor_config.h:122
std::function< void(actor_ptr_t &)> install_action_t
actor post-constructor callback type
Definition actor_config.h:107
install_action_t install_action
post-construction callback
Definition actor_config.h:119
basic actor configuration: init and shutdown timeouts, etc.
Definition actor_config.h:62
std::function< plugin_storage_ptr_t()> plugins_constructor_t
constructs plugin_storage_ptr_t (type)
Definition actor_config.h:64
pt::time_duration init_timeout
max actor initialization time
Definition actor_config.h:73
supervisor_t * supervisor
raw pointer to supervisor_t
Definition actor_config.h:70
actor_config_t(supervisor_t *supervisor_)
constructs actor_config_t from raw supervisor pointer
Definition actor_config.h:88
pt::time_duration shutdown_timeout
max actor shutdown time
Definition actor_config.h:76
plugins_constructor_t plugins_constructor
constructs plugin_storage_ptr_t
Definition actor_config.h:67
address_ptr_t spawner_address
address of the spawner
Definition actor_config.h:79
abstract item to store plugins inside actor
Definition actor_config.h:30
virtual plugins_t get_plugins() noexcept=0
returns list of plugins pointers from the storage
templated plugin storage implementation
Definition actor_config.h:41
plugins_t get_plugins() noexcept override
returns list of plugins pointers from the storage
Definition actor_config.h:42
supervisor is responsible for managing actors (workers) lifetime
Definition supervisor.h:69
The system context holds root supervisor_t (intrusive pointer) and may be loop-related details in der...
Definition system_context.h:32