rotor
Event loop friendly C++ actor micro-framework
 
Loading...
Searching...
No Matches
supervisor_fltk.h
1#pragma once
2
3//
4// Copyright (c) 2019-2024 Ivan Baidakou (basiliscos) (the dot dmol at gmail dot com)
5//
6// Distributed under the MIT Software License
7//
8
9#include "rotor/supervisor.h"
10#include "rotor/fltk/export.h"
11#include "rotor/fltk/supervisor_config_fltk.h"
12
13#include <memory>
14#include <unordered_map>
15
16namespace rotor {
17namespace fltk {
18
38struct ROTOR_FLTK_API supervisor_fltk_t : public supervisor_t {
41
43 template <typename Supervisor> using config_builder_t = supervisor_config_fltk_builder_t<Supervisor>;
44
47
48 void start() noexcept override;
49 void shutdown() noexcept override;
50 void enqueue(message_ptr_t message) noexcept override;
51
53 template <typename T> auto &access() noexcept;
54
71
72 protected:
74 using timer_ptr_t = std::unique_ptr<timer_t>;
75
77 using timers_map_t = std::unordered_map<request_id_t, timer_ptr_t>;
78
79 void do_start_timer(const pt::time_duration &interval, timer_handler_base_t &handler) noexcept override;
80 void do_cancel_timer(request_id_t timer_id) noexcept override;
81
84};
85
86} // namespace fltk
87} // namespace rotor
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
std::size_t request_id_t
timer identifier type in the scope of the actor
Definition forward.hpp:34
boost::intrusive_ptr< T > intrusive_ptr_t
alias for intrusive pointer
Definition arc.hpp:27
timer structure, adopted for fltk-supervisor needs.
Definition supervisor_fltk.h:58
supervisor_ptr_t sup
intrusive pointer to the supervisor
Definition supervisor_fltk.h:66
timer_t(supervisor_ptr_t supervisor, timer_handler_base_t *handler)
constructs timer from flt supervisor and timer handler
intrusive_ptr_t< supervisor_fltk_t > supervisor_ptr_t
alias for intrusive pointer for the fltk supervisor
Definition supervisor_fltk.h:60
timer_handler_base_t * handler
non-owning pointer to timer handler
Definition supervisor_fltk.h:69
delivers rotor-messages on top of fltk async callback
Definition supervisor_fltk.h:38
timers_map_t timers_map
timer id to timer pointer mapping
Definition supervisor_fltk.h:83
supervisor_fltk_t(supervisor_config_fltk_t &config)
constructs new supervisor from supervisor config
void do_cancel_timer(request_id_t timer_id) noexcept override
cancels timer (to be implemented in descendants)
void start() noexcept override
thread-safe version of do_process
std::unique_ptr< timer_t > timer_ptr_t
unique pointer to timer
Definition supervisor_fltk.h:74
std::unordered_map< request_id_t, timer_ptr_t > timers_map_t
timer id to timer pointer mapping type
Definition supervisor_fltk.h:77
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)
CRTP supervisor config builder.
Definition supervisor_config.h:72
base supervisor config, which holds shutdown timeout value
Definition supervisor_config.h:23
supervisor is responsible for managing actors (workers) lifetime
Definition supervisor.h:69
Base class for timer handler.
Definition timer_handler.hpp:17