9#include "rotor/forward.hpp"
10#include "rotor/policy.h"
15#pragma warning(disable : 4251)
18namespace rotor::detail {
20enum class shutdown_state_t { none, sent, confirmed };
28using spawn_demand_t = std::variant<demand::no, demand::now, demand::escalate_failure, pt::time_duration>;
36struct ROTOR_API
child_info_t : boost::intrusive_ref_counter<child_info_t, boost::thread_unsafe_counter> {
41 template <
typename Factory>
43 const pt::time_duration &restart_period_ = pt::seconds{15},
size_t max_attempts_ = 0,
44 bool escalate_failure_ =
false)
noexcept
45 : address{std::move(address_)}, factory{std::forward<Factory>(factory_)}, policy{policy_},
46 restart_period{restart_period_}, max_attempts{max_attempts_}, escalate_failure{escalate_failure_} {}
49 template <
typename Factory,
typename Actor>
51 :
child_info_t(std::move(address_), std::forward<Factory>(factory_)) {
52 actor = std::forward<Actor>(actor_);
73 spawn_demand_t next_spawn(
bool abnormal_shutdown) noexcept;
88 pt::time_duration restart_period;
91 shutdown_state_t shutdown = shutdown_state_t::none;
103 bool escalate_failure = false;
112 bool initialized =
false;
115 bool started =
false;
118using child_info_ptr_t = boost::intrusive_ptr<child_info_t>;
intrusive_ptr_t< address_t > address_ptr_t
intrusive pointer for address
Definition address.hpp:57
restart_policy_t
spawner's actor restart policy
Definition policy.h:23
intrusive_ptr_t< actor_base_t > actor_ptr_t
intrusive pointer for actor
Definition forward.hpp:23
std::size_t request_id_t
timer identifier type in the scope of the actor
Definition forward.hpp:34
std::function< actor_ptr_t(supervisor_t &, const address_ptr_t &)> factory_t
factory which allows to create actors lazily or on demand
Definition forward.hpp:45
Child actor runtime housekeeping information.
Definition child_info.h:36
pt::microsec_clock clock_t
an alias for used microsec clock
Definition child_info.h:38
child_info_t(address_ptr_t address_, Factory &&factory_, restart_policy_t policy_=restart_policy_t::normal_only, const pt::time_duration &restart_period_=pt::seconds{15}, size_t max_attempts_=0, bool escalate_failure_=false) noexcept
CTOR for spawner-instantiated actor.
Definition child_info.h:42
pt::ptime last_instantiation
when an actor was successfully spawned
Definition child_info.h:109
void spawn_attempt() noexcept
recalculates the state upon spawn_attempt
child_info_t(address_ptr_t address_, Factory &&factory_, Actor &&actor_) noexcept
CTOR for manually instantiated actor.
Definition child_info.h:50
Definition child_info.h:25
Definition child_info.h:23
Definition child_info.h:24