11#include "actor_config.h"
12#include "messages.hpp"
15#include "extended_error.h"
16#include "timer_handler.hpp"
21#pragma warning(disable : 4251)
59 template <
typename Handler>
61 std::enable_if_t<std::is_member_function_pointer_v<Handler> || std::is_base_of_v<handler_base_t, Handler>>;
125 template <typename M, typename... Args>
void send(const
address_ptr_t &addr, Args &&...args);
134 template <typename R, typename... Args>
148 template <typename R, typename... Args>
156 template <typename Request, typename... Args>
void reply_to(Request &message, Args &&...args);
159 template <typename Request>
void reply_with_error(Request &message, const
extended_error_ptr_t &ec);
169 template <typename Request, typename... Args> auto make_response(Request &message, Args &&...args);
179 template <typename Request> auto make_response(Request &message, const
extended_error_ptr_t &ec);
188 template <typename Handler, typename =
is_handler<Handler>>
192 template <typename Handler, typename =
is_handler<Handler>>
void unsubscribe(Handler &&h) noexcept;
205 inline
void unsubscribe(const
handler_ptr_t &h) noexcept { lifetime->unsubscribe(h, address); }
211 void commit_plugin_activation(plugin::plugin_base_t &plugin,
bool success) noexcept;
214 void deactivate_plugins() noexcept;
217 void commit_plugin_deactivation(plugin::plugin_base_t &plugin) noexcept;
223 void on_unsubscription(message::unsubscription_t &message) noexcept;
226 void on_unsubscription_external(message::unsubscription_external_t &message) noexcept;
236 virtual
void shutdown_start() noexcept;
245 void shutdown_continue() noexcept;
258 virtual
void shutdown_finish() noexcept;
265 virtual
void init_start() noexcept;
274 void init_continue() noexcept;
281 virtual
void init_finish() noexcept;
284 virtual
void configure(plugin::plugin_base_t &plugin) noexcept;
287 template <typename T> auto &access() noexcept;
290 template <typename T, typename... Args> auto access(Args... args) noexcept;
293 template <typename T> auto &access() const noexcept;
296 template <typename T, typename... Args> auto access(Args... args) const noexcept;
299 inline const
address_ptr_t &get_address() const noexcept {
return address; }
322 template <
typename Delegate,
typename Method,
323 typename = std::enable_if_t<std::is_invocable_v<Method, Delegate *, request_id_t, bool>>>
324 request_id_t start_timer(
const pt::time_duration &interval, Delegate &delegate, Method method)
noexcept;
347 inline const std::string &
get_identity() const noexcept {
return identity; }
350 static const constexpr std::uint32_t PROGRESS_INIT = 1 << 0;
353 static const constexpr std::uint32_t PROGRESS_SHUTDOWN = 1 << 1;
363 static const constexpr std::uint32_t ESCALATE_FALIURE = 1 << 2;
373 static const constexpr std::uint32_t AUTOSHUTDOWN_SUPERVISOR = 1 << 3;
395 void on_timer_trigger(
request_id_t request_id,
bool cancelled) noexcept;
398 template <typename Delegate, typename Method>
399 void start_timer(
request_id_t request_id, const pt::time_duration &interval, Delegate &delegate,
400 Method method) noexcept;
486 std::uint32_t continuation_mask = 0;
495 template <
typename T,
typename M>
friend struct accessor_t;
Basic namespace for all rotor functionalities.
Definition rotor.hpp:21
intrusive_ptr_t< message_base_t > message_ptr_t
intrusive pointer for message
Definition message.h:118
intrusive_ptr_t< address_t > address_ptr_t
intrusive pointer for address
Definition address.hpp:57
intrusive_ptr_t< extended_error_t > extended_error_ptr_t
intrusive pointer to extended error type
Definition extended_error.h:25
std::unique_ptr< plugin_storage_base_t > plugin_storage_ptr_t
smart pointer for plugin_storage_base_t
Definition actor_config.h:38
state_t
state of actor in rotor
Definition state.h:12
boost::intrusive_ref_counter< T, counter_policy_t > arc_base_t
base class to inject ref-counter with the specified policy
Definition arc.hpp:24
intrusive_ptr_t< handler_base_t > handler_ptr_t
intrusive pointer for handler
Definition forward.hpp:26
std::size_t request_id_t
timer identifier type in the scope of the actor
Definition forward.hpp:34
intrusive_ptr_t< subscription_info_t > subscription_info_ptr_t
intrusive pointer for subscription_info_t
Definition subscription_point.h:127
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
std::unique_ptr< timer_handler_base_t > timer_handler_ptr_t
alias for timer smart pointer
Definition timer_handler.hpp:36
universal primitive of concurrent computation
Definition actor_base.h:47
std::enable_if_t< std::is_member_function_pointer_v< Handler >||std::is_base_of_v< handler_base_t, Handler > > is_handler
SFINAE handler detector.
Definition actor_base.h:61
timers_map_t timers_map
timer-id to timer-handler map
Definition actor_base.h:474
pt::time_duration init_timeout
timeout for actor initialization (used by supervisor)
Definition actor_base.h:441
pt::time_duration shutdown_timeout
timeout for actor shutdown (used by supervisor)
Definition actor_base.h:444
std::tuple< plugin::address_maker_plugin_t, plugin::lifetime_plugin_t, plugin::init_shutdown_plugin_t, plugin::link_server_plugin_t, plugin::link_client_plugin_t, plugin::registry_plugin_t, plugin::resources_plugin_t, plugin::starter_plugin_t > plugins_list_t
the default list of plugins for an actor
Definition actor_base.h:78
virtual void do_shutdown(const extended_error_ptr_t &reason={}) noexcept
convenient method to send actor's supervisor shutdown trigger message
requests_t active_requests
list of ids of active requests
Definition actor_base.h:477
virtual bool should_restart() const noexcept
whether spawner should create a new instance of the actor
void activate_plugins() noexcept
starts plugins activation
std::set< const std::type_index * > deactivating_plugins
set of deactivating plugin identities
Definition actor_base.h:471
std::unordered_set< request_id_t > requests_t
list of ids of active requests (type)
Definition actor_base.h:392
actor_base_t(config_t &cfg)
constructs actor and links it's supervisor
supervisor_t & get_supervisor() const noexcept
returns actor's supervisor
Definition actor_base.h:302
const std::string & get_identity() const noexcept
retuns human-readable actor identity
Definition actor_base.h:347
plugins_t plugins
non-owning list of plugins
Definition actor_base.h:438
plugin_storage_ptr_t plugins_storage
opaque plugins storage (owning)
Definition actor_base.h:435
plugin::plugin_base_t * get_plugin(const std::type_index &) const noexcept
finds plugin by plugin class identity
address_ptr_t spawner_address
actor spawner address
Definition actor_base.h:426
std::set< const std::type_index * > activating_plugins
set of activating plugin identities
Definition actor_base.h:468
const extended_error_ptr_t & get_shutdown_reason() const noexcept
returns actor shutdown reason
Definition actor_base.h:340
virtual void on_start() noexcept
actor is fully initialized and it's supervisor has sent signal to start
virtual void do_initialize(system_context_t *ctx) noexcept
early actor initialization (pre-initialization)
intrusive_ptr_t< message::init_request_t > init_request
suspended init request message
Definition actor_base.h:417
extended_error_ptr_t shutdown_reason
explanation, why actor is been requested for shut down
Definition actor_base.h:489
state_t state
current actor state
Definition actor_base.h:447
supervisor_t * supervisor
non-owning pointer to actor's execution / infrastructure context
Definition actor_base.h:432
std::unordered_map< request_id_t, timer_handler_ptr_t > timers_map_t
timer-id to timer-handler map (type)
Definition actor_base.h:389
void cancel_timer(request_id_t request_id) noexcept
cancels previously started timer
intrusive_ptr_t< message::shutdown_request_t > shutdown_request
suspended shutdown request message
Definition actor_base.h:420
virtual bool on_unlink(const address_ptr_t &server_addr) noexcept
notification, when actor has been unlinked from server actor
address_ptr_t address
actor address
Definition actor_base.h:423
std::string identity
actor identity, which might have some meaning for developers
Definition actor_base.h:429
CRTP actor config builder.
Definition actor_config.h:92
basic actor configuration: init and shutdown timeouts, etc.
Definition actor_config.h:62
create actor's addresses
Definition address_maker.h:24
manages actors init and shutdown procedures
Definition init_shutdown.h:22
manages all actor subscriptions (i.e. from plugins or actor itself).
Definition lifetime.h:21
allows actor to have active (client) role in linking
Definition link_client.h:34
allows actor to have passive (server) role in linking
Definition link_server.h:32
base class for all actor plugins
Definition plugin_base.h:23
handy access to registry_t, for name registration and discovery
Definition registry.h:35
"lock" for external resources
Definition resources.h:39
allows custom (actor) subscriptions and it is responsible for starting actor when it receives message...
Definition starter.h:19
builder pattern implementation for the original request
Definition request.hpp:387
optionally wraps request type into intrusive pointer
Definition request.hpp:43
Holds and classifies message handlers on behalf of supervisor.
Definition subscription.h:30
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