rotor
Event loop friendly C++ actor micro-framework
 
Loading...
Searching...
No Matches
system_context.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 "address.hpp"
10#include "supervisor_config.h"
11#include "extended_error.h"
12#include "message_stringifier.h"
13
14#include <system_error>
15
16#if defined(_MSC_VER)
17#pragma warning(push)
18#pragma warning(disable : 4251)
19#endif
20
21namespace rotor {
22
23struct supervisor_t;
24struct actor_base_t;
25using supervisor_ptr_t = intrusive_ptr_t<supervisor_t>;
26
32struct ROTOR_API system_context_t : arc_base_t<system_context_t> {
33 public:
35 template <typename Supervisor = supervisor_t> auto create_supervisor();
36
38 inline supervisor_ptr_t get_supervisor() noexcept { return supervisor; }
39
40 system_context_t() = default;
41
42 system_context_t(const system_context_t &) = delete;
44 virtual ~system_context_t();
45
53 virtual void on_error(actor_base_t *actor, const extended_error_ptr_t &ec) noexcept;
54
60 virtual std::string identity() noexcept;
61
63 template <typename T> auto &access() noexcept;
64
70 const message_stringifier_t &get_stringifier();
71
72 protected:
74 virtual message_stringifier_ptr_t make_stringifier() const noexcept;
75
76 private:
77 friend struct supervisor_t;
78 supervisor_ptr_t supervisor;
79 message_stringifier_ptr_t stringifier;
80};
81
84
85} // namespace rotor
86
87#if defined(_MSC_VER)
88#pragma warning(pop)
89#endif
Basic namespace for all rotor functionalities.
Definition rotor.hpp:21
intrusive_ptr_t< supervisor_t > supervisor_ptr_t
intrusive pointer for supervisor
Definition forward.hpp:29
intrusive_ptr_t< extended_error_t > extended_error_ptr_t
intrusive pointer to extended error type
Definition extended_error.h:25
intrusive_ptr_t< system_context_t > system_context_ptr_t
intrusive pointer for system context
Definition system_context.h:83
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
std::unique_ptr< message_stringifier_t > message_stringifier_ptr_t
smart pointer for message stringifier
Definition message_stringifier.h:47
boost::intrusive_ptr< T > intrusive_ptr_t
alias for intrusive pointer
Definition arc.hpp:27
universal primitive of concurrent computation
Definition actor_base.h:47
Abstract interface for making textual/string representation of a message.
Definition message_stringifier.h:36
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
virtual void on_error(actor_base_t *actor, const extended_error_ptr_t &ec) noexcept
fatal error handler
virtual std::string identity() noexcept
identifies the context.
supervisor_ptr_t get_supervisor() noexcept
returns root supervisor
Definition system_context.h:38