9#include "rotor/supervisor.h"
10#include "rotor/asio/export.h"
11#include "supervisor_config_asio.h"
12#include "system_context_asio.h"
13#include "forwarder.hpp"
14#include <boost/asio.hpp>
15#include <unordered_map>
20#pragma warning(disable : 4251)
26namespace asio = boost::asio;
27namespace sys = boost::system;
29template <
typename Actor,
typename Handler,
typename ArgsCount,
typename ErrHandler>
struct forwarder_t;
69 virtual
void start() noexcept override;
70 virtual
void shutdown() noexcept override;
72 virtual
void shutdown_finish() noexcept override;
75 template <typename Handler, typename ErrHandler>
76 auto create_forwarder(Handler &&handler, ErrHandler &&err_handler) {
77 return forwarder_t{*
this, std::move(handler), std::move(err_handler)};
86 inline asio::io_context::strand &
get_strand() noexcept {
return *strand; }
94 struct
timer_t : public asio::deadline_timer {
101 : asio::deadline_timer(io_context), handler{handler_} {}
114 using guard_t = asio::executor_work_guard<asio::io_context::executor_type>;
129 void invoke_shutdown() noexcept;
132template <typename Actor> inline boost::asio::io_context::strand &get_strand(Actor &actor) {
133 return actor.get_strand();
forwarder_t(Actor &, Handler &&) -> forwarder_t< Actor, Handler, typename details::callback_traits< Handler >::args_count, void >
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
std::size_t request_id_t
timer identifier type in the scope of the actor
Definition forward.hpp:34
Definition forwarder.hpp:111
boos::asio::deadline_timer with embedded timer handler
Definition supervisor_asio.h:94
timer_t(timer_handler_base_t *handler_, asio::io_context &io_context)
constructs timer using timer handler and boost asio io_context
Definition supervisor_asio.h:100
timer_handler_base_t * handler
non-owning pointer to timer handler
Definition supervisor_asio.h:97
delivers rotor-messages on top of boost asio event loop using strand for serialization
Definition supervisor_asio.h:56
timers_map_t timers_map
timer id to timer pointer mapping
Definition supervisor_asio.h:120
void do_cancel_timer(request_id_t timer_id) noexcept override
cancels timer (to be implemented in descendants)
std::unique_ptr< timer_t > timer_ptr_t
unique pointer to timer
Definition supervisor_asio.h:105
guard_ptr_t guard
guard to control ownership of the io-context
Definition supervisor_asio.h:126
void do_start_timer(const pt::time_duration &interval, timer_handler_base_t &handler) noexcept override
starts non-recurring timer (to be implemented in descendants)
virtual address_ptr_t make_address() noexcept override
creates new address_t linked with the supervisor
std::unordered_map< request_id_t, timer_ptr_t > timers_map_t
timer id to timer pointer mapping type
Definition supervisor_asio.h:108
asio::executor_work_guard< asio::io_context::executor_type > guard_t
guard type : alias for asio executor_work_guard
Definition supervisor_asio.h:114
supervisor_config_asio_t::strand_ptr_t strand
config for the supervisor
Definition supervisor_asio.h:123
supervisor_asio_t(supervisor_config_asio_t &config)
constructs new supervisor from asio supervisor config
std::unique_ptr< guard_t > guard_ptr_t
alias for a guard
Definition supervisor_asio.h:117
void do_process() noexcept
process queue of messages of locality leader
asio::io_context::strand & get_strand() noexcept
returns execution strand
Definition supervisor_asio.h:86
auto create_forwarder(Handler &&handler)
an helper for creation forwarder_t (no-error handler case)
Definition supervisor_asio.h:81
CRTP supervisor asio config builder.
Definition supervisor_config_asio.h:40
boost::asio supervisor config, which holds pointer to strand
Definition supervisor_config_asio.h:23
std::shared_ptr< strand_t > strand_ptr_t
type for strand shared pointer
Definition supervisor_config_asio.h:28
supervisor is responsible for managing actors (workers) lifetime
Definition supervisor.h:69
Base class for timer handler.
Definition timer_handler.hpp:17