7#include "definitions.hpp"
11namespace rotor_light {
93 template <
typename Ctx>
94 EventId
add_event(Duration delta, Callback callback,
void *data);
108 template <
typename Ctx,
typename MessageType,
typename... Args>
109 bool send(
size_t queue_index, Args... args);
115 template <
typename Method>
void subscribe(Method method) {
116 assert(
state == State::off);
117 assert(backend_idx < (
int)backends_count);
118 auto ptr = backends_ptr + ++backend_idx *
sizeof(
Handler);
119 make_handler(method, *
reinterpret_cast<Handler *
>(ptr));
188 template <
typename Method>
189 void make_handler(Method &method,
Handler &handler) {
191 using FinalMessage =
typename traits::FinalMessage;
192 using Backend =
typename traits::Backend;
196 auto &final_message =
static_cast<FinalMessage &
>(message);
197 auto &backend =
static_cast<Backend &
>(actor);
198 (backend.*
reinterpret_cast<Method &
>(handler.
method))(final_message);
204 size_t backends_count;
207 friend struct SupervisorBase;
214 "no enough handlers");
runtime info about message subscription handler
Definition: actor.hpp:42
MessageTypeId message_id
holds message_id to do runtime message matching
Definition: actor.hpp:47
MethodEntry entry
Method entry item.
Definition: actor.hpp:50
GenericMethod method
holds pointer-to-member-function for message processing
Definition: actor.hpp:44
A Backend
final actor type
Definition: actor.hpp:32
M FinalMessage
messsage type
Definition: actor.hpp:29
helps method signature extraction
Definition: actor.hpp:25
base interface and implementation for all actors, including supervisors
Definition: actor.hpp:19
ActorId mask
Definition: actor.hpp:174
void subscribe(Method method)
Definition: actor.hpp:115
State state
Definition: actor.hpp:177
void(ActorBase::*)(Message &) GenericMethod
alias for generic message handler
Definition: actor.hpp:21
virtual void initialize()
FailPolicy fail_policy
Definition: actor.hpp:183
bool send(size_t queue_index, Args... args)
emplaces new message into appropriate queue
Definition: supervisor.hpp:193
ActorId get_id() const
Definition: actor.hpp:72
virtual uint8_t bind(ActorId initial_value, SupervisorBase *supervisor, Context &context)
FailPolicy get_fail_policy() const
Definition: actor.hpp:78
void set_fail_policy(FailPolicy value)
Definition: actor.hpp:81
State get_state() const
Definition: actor.hpp:75
virtual void advance_init()
EventId add_event(Duration delta, Callback callback, void *data)
Definition: supervisor.hpp:207
void(*)(Message &, ActorBase &, Handler &) MethodEntry
alias for method entry, enough to actually perfrom message delivery
Definition: actor.hpp:38
ActorBase(char *backends, size_t backends_count)
void cancel_event(EventId event_id)
static constexpr size_t min_handlers_amount
Definition: actor.hpp:55
SupervisorBase * supervisor
Definition: actor.hpp:180
ActorId id
Definition: actor.hpp:165
virtual void advance_stop()
virtual void advance_start()
convenient templated base class for user-defined actors
Definition: actor.hpp:212
ActorBase::Handler backends[HandlersCount]
Definition: actor.hpp:218
root supervisor initialization tuple
Definition: context.hpp:18
base class for all rotor-light messages
Definition: message.hpp:22
base interface and implementation for all supervisors
Definition: supervisor.hpp:29
State Change command, from supervisor/actor to actor.
Definition: messages.hpp:14