SObjectizer 5.8
Loading...
Searching...
No Matches
subscription_storage_iface.hpp
Go to the documentation of this file.
1/*
2 * SObjectizer-5
3 */
4
5/*!
6 * \since
7 * v.5.5.3
8 *
9 * \file
10 * \brief An interface of subscription storage.
11 */
12
13#pragma once
14
15#include <so_5/types.hpp>
16
17#include <so_5/mbox.hpp>
18#include <so_5/state.hpp>
19#include <so_5/execution_demand.hpp>
20#include <so_5/subscription_storage_fwd.hpp>
21
22#include <functional>
23#include <ostream>
24#include <sstream>
25#include <vector>
26
27namespace so_5
28{
29
30namespace impl
31{
32
33//
34// event_handler_data_t
35//
36/*!
37 * \since
38 * v.5.4.0
39 *
40 * \brief Information about event_handler and its properties.
41 */
43 {
44 //! Method for handling event.
45 event_handler_method_t m_method;
46 //! Is event handler thread safe or not.
48 //! Kind of this event handler.
49 /*!
50 * \since
51 * v.5.7.0
52 */
54
56 event_handler_method_t method,
57 thread_safety_t thread_safety,
59 : m_method( std::move( method ) )
60 , m_thread_safety( thread_safety )
61 , m_kind( kind )
62 {}
63 };
64
65/*!
66 * \since
67 * v.5.5.3
68 *
69 * \brief Common stuff for various subscription storage implementations.
70 */
72{
73
74/*!
75 * \since
76 * v.5.5.3
77 *
78 * \brief An information about one subscription.
79 */
81 {
82 //! Reference to mbox.
83 /*!
84 * Reference must be stored because we must have
85 * access to mbox during destroyment of all
86 * subscriptions in destructor.
87 */
88 mbox_t m_mbox;
89 std::type_index m_msg_type;
90 //! Message sink used for subscription.
91 std::reference_wrapper< abstract_message_sink_t > m_message_sink;
92 const state_t * m_state;
94
96 mbox_t mbox,
97 std::type_index msg_type,
98 abstract_message_sink_t & message_sink,
99 const state_t & state,
100 const event_handler_method_t & method,
101 thread_safety_t thread_safety,
102 event_handler_kind_t handler_kind )
103 : m_mbox( std::move( mbox ) )
104 , m_msg_type( std::move( msg_type ) )
105 , m_message_sink( message_sink )
106 , m_state( &state )
107 , m_handler( method, thread_safety, handler_kind )
108 {}
109 };
110
111/*!
112 * \since
113 * v.5.5.3
114 *
115 * \brief Type of vector with subscription information.
116 */
117using subscr_info_vector_t = std::vector< subscr_info_t >;
118
119/*!
120 * \since
121 * v.5.5.3
122 *
123 * \brief A helper function for creating subscription description.
124 */
125inline std::string
127 const mbox_t & mbox_ref,
128 std::type_index msg_type,
129 const state_t & state )
130 {
131 std::ostringstream s;
132 s << "(mbox:'" << mbox_ref->query_name()
133 << "', msg_type:'" << msg_type.name() << "', state:'"
134 << state.query_name() << "')";
135
136 return s.str();
137 }
138
139} /* namespace subscription_storage_common */
140
141/*!
142 * \since
143 * v.5.5.3
144 *
145 * \brief An interface of subscription storage
146 *
147 * Prior to v.5.5.3 there where only one subscription_storage implementation.
148 * But this implementation was not efficient for all cases.
149 *
150 * Sometimes an agent has very few subscriptions and efficient
151 * implementation for that case can be based on std::vector.
152 * Sometimes an agent has very many subscriptions and efficient
153 * implementation can require std::map or std::unordered_map.
154 *
155 * The purpose of this interface is hiding details of concrete
156 * subscription_storage implementation.
157 */
159 {
160 public :
162 virtual ~subscription_storage_t() noexcept = default;
163
164 virtual void
166 const mbox_t & mbox,
167 const std::type_index & msg_type,
168 abstract_message_sink_t & message_sink,
169 const state_t & target_state,
170 const event_handler_method_t & method,
171 thread_safety_t thread_safety,
172 event_handler_kind_t handler_kind ) = 0;
173
174 virtual void
176 const mbox_t & mbox,
177 const std::type_index & msg_type,
178 const state_t & target_state ) noexcept = 0;
179
180 virtual void
182 const mbox_t & mbox,
183 const std::type_index & msg_type ) noexcept = 0;
184
185 /*!
186 * \brief Drop all subscriptions.
187 *
188 * All subscribed event-handlers have to be unsubscribed.
189 * The object should remain in the valid state and creation
190 * of new subscriptions have to be allowed.
191 *
192 * This method is intended to be used when an agents what
193 * to erase all subscriptions at once.
194 *
195 * \since v.5.7.3
196 */
197 virtual void
199
200 virtual const event_handler_data_t *
202 mbox_id_t mbox_id,
203 const std::type_index & msg_type,
204 const state_t & current_state ) const noexcept = 0;
205
206 virtual void
207 debug_dump( std::ostream & to ) const = 0;
208
209 //! Drop all content.
210 /*!
211 * All information about subscription must be erased,
212 * but without real unsubscription.
213 *
214 * This method will be called after successful copy of
215 * subscription information to another storage.
216 */
217 virtual void
218 drop_content() noexcept = 0;
219
220 //! Get content for copying subscription information
221 //! to another storage object.
222 virtual subscription_storage_common::subscr_info_vector_t
223 query_content() const = 0;
224
225 //! Setup content from information from another storage object.
226 virtual void
228 subscription_storage_common::subscr_info_vector_t && info ) = 0;
229
230 //! Count of subscriptions in the storage.
231 virtual std::size_t
233 };
234
235} /* namespace impl */
236
237} /* namespace so_5 */
virtual void unsubscribe_event_handler(const std::type_index &type_index, abstract_message_sink_t &subscriber) noexcept=0
Remove all message handlers.
virtual void subscribe_event_handler(const std::type_index &type_index, abstract_message_sink_t &subscriber)=0
Add the message handler.
virtual so_5::environment_t & environment() const noexcept=0
SObjectizer Environment for which the mbox is created.
abstract_message_box_t(const abstract_message_box_t &)=delete
virtual void drop_delivery_filter(const std::type_index &msg_type, abstract_message_sink_t &subscriber) noexcept=0
Removes delivery filter for message type and subscriber.
virtual void set_delivery_filter(const std::type_index &msg_type, const delivery_filter_t &filter, abstract_message_sink_t &subscriber)=0
Set a delivery filter for message type and subscriber.
virtual ~abstract_message_box_t() noexcept=default
virtual mbox_id_t id() const =0
Unique ID of this mbox.
virtual std::string query_name() const =0
Get the mbox name.
abstract_message_box_t & operator=(abstract_message_box_t &&)=delete
virtual void do_deliver_message(message_delivery_mode_t delivery_mode, const std::type_index &msg_type, const message_ref_t &message, unsigned int redirection_deep)=0
Deliver message for all subscribers with respect to message limits.
abstract_message_box_t & operator=(const abstract_message_box_t &)=delete
virtual mbox_type_t type() const =0
Get the type of message box.
abstract_message_box_t(abstract_message_box_t &&)=delete
An interace of message chain.
Definition mchain.hpp:447
~abstract_message_chain_t() noexcept override=default
virtual void actual_close(mchain_props::close_mode_t mode)=0
Close the chain.
virtual mchain_props::push_status_t push(const std::type_index &msg_type, const message_ref_t &message, mchain_props::select_case_t &select_case)=0
An attempt to push a new message into the mchain.
virtual std::size_t size() const =0
Count of messages in the chain.
void close(Exceptions_Control, mchain_props::close_mode_t mode) noexcept(noexcept(details::should_terminate_if_throws_t< Exceptions_Control >::value))
Close the chain.
Definition mchain.hpp:545
virtual void remove_from_select(mchain_props::select_case_t &select_case) noexcept=0
Removement of mchain from multi chain select.
abstract_message_chain_t(const abstract_message_chain_t &)=delete
so_5::mbox_t as_mbox()
Cast message chain to message box.
Definition mchain.cpp:21
virtual mchain_props::extraction_status_t extract(mchain_props::demand_t &dest, mchain_props::select_case_t &select_case)=0
An extraction attempt as a part of multi chain select.
virtual bool empty() const =0
Is message chain empty?
abstract_message_chain_t & operator=(const abstract_message_chain_t &)=delete
virtual mchain_props::extraction_status_t extract(mchain_props::demand_t &dest, mchain_props::duration_t empty_queue_timeout)=0
Interface for message sink.
abstract_message_sink_t & operator=(const abstract_message_sink_t &)=default
abstract_message_sink_t(const abstract_message_sink_t &)=default
abstract_message_sink_t(abstract_message_sink_t &&) noexcept=default
abstract_message_sink_t & operator=(abstract_message_sink_t &&) noexcept=default
static bool special_sink_ptr_compare(const abstract_message_sink_t *a, const abstract_message_sink_t *b) noexcept
virtual void push_event(mbox_id_t mbox_id, message_delivery_mode_t delivery_mode, const std::type_index &msg_type, const message_ref_t &message, unsigned int redirection_deep, const message_limit::impl::action_msg_tracer_t *tracer)=0
Get a message and push it to the appropriate destination.
virtual priority_t sink_priority() const noexcept=0
Get the priority for the message sink.
virtual environment_t & environment() const noexcept=0
virtual ~abstract_message_sink_t() noexcept=default
Interface for holders of message_sink instances.
virtual const abstract_message_sink_t & sink() const noexcept=0
Get a const reference to the underlying message sink.
virtual abstract_message_sink_t & sink() noexcept=0
Get a reference to the underlying message sink.
virtual ~abstract_sink_owner_t() noexcept=default
A context for agent construction and tuning.
environment_t * m_env
SObjectizer Environment to work in.
agent_context_t(environment_t &env, agent_tuning_options_t options)
const agent_tuning_options_t & options() const
Read-only access to agent options.
agent_context_t(environment_t &env)
Constructor for the case when only environment available.
environment_t & environment() const
Access to SObjectizer Environment.
agent_tuning_options_t & options()
Read-Write access to agent options.
friend void swap(so_5::agent_context_t &a, so_5::agent_context_t &b) noexcept
Swap operation.
agent_tuning_options_t m_options
Options for agent tuning.
environment_t & env() const
Access to SObjectizer Environment.
Helper class for holding agent's identity (name or pointer).
std::string_view actual_name() const noexcept
Attempt to get an agent name.
std::string to_string() const
Transform identity into a string.
agent_identity_t(std::string_view name) noexcept
Initializing constructor for case when agent has a user specified name.
bool has_actual_name() const noexcept
Does agent have an actual name?
value_t m_value
Agent's identity.
agent_identity_t(const agent_t *pointer) noexcept
Initializing constructor for case when agent has no user specified name.
Interface of the agent state listener.
virtual ~agent_state_listener_t() noexcept=default
agent_state_listener_t(const agent_state_listener_t &)=delete
agent_state_listener_t & operator=(const agent_state_listener_t &)=delete
virtual void changed(agent_t &agent, const state_t &state) noexcept=0
Hook method for state changes.
A base class for agents.
Definition agent.hpp:673
void so_subscribe_deadletter_handler(const so_5::mbox_t &mbox, Event_Handler &&handler, thread_safety_t thread_safety=thread_safety_t::unsafe)
Create a subscription for deadletter handler for a specific message from a specific mbox.
Definition agent.hpp:2080
static demand_handler_pfn_t get_demand_handler_on_start_ptr() noexcept
Definition agent.cpp:1323
impl::state_listener_controller_t m_state_listener_controller
State listeners controller.
Definition agent.hpp:2803
decltype(auto) so_low_level_exec_as_event_handler(Lambda &&lambda) noexcept(noexcept(lambda()))
Helper method that allows to run a block of code as non-thread-safe event handler.
Definition agent.hpp:2630
static void process_enveloped_msg(current_thread_id_t working_thread_id, execution_demand_t &d, const impl::event_handler_data_t *handler_data)
Actual implementation of enveloped message handling.
Definition agent.cpp:1445
std::unique_ptr< impl::sinks_storage_t > m_message_sinks
Holder of message sinks for that agent.
Definition agent.hpp:2843
const state_t st_default
Definition agent.hpp:2774
bool so_has_subscription(const mbox_t &mbox) const noexcept
Check the presence of a subscription in the default_state.
Definition agent.hpp:1856
void do_change_agent_state(const state_t &state_to_be_set)
Perform actual operations related to state switch.
Definition agent.cpp:1637
void so_drop_delivery_filter(const mbox_t &mbox) noexcept
Drop a delivery filter.
Definition agent.hpp:2531
void so_initiate_agent_definition()
A correct initiation of so_define_agent method call.
Definition agent.cpp:829
const agent_t * self_ptr() const
Get the raw pointer of itself.
Definition agent.hpp:834
so_5::current_thread_id_t m_working_thread_id
Working thread id.
Definition agent.hpp:2899
default_rw_spinlock_t m_event_queue_lock
Event queue operation protector.
Definition agent.hpp:2867
bool so_has_subscription(const mbox_t &mbox, const state_t &target_state) const noexcept
Check the presence of a subscription.
Definition agent.hpp:1811
std::enable_if< details::is_agent_method_pointer< details::method_arity::unary, Method_Pointer >::value, bool >::type so_has_subscription(const mbox_t &mbox, Method_Pointer) const noexcept
Check the presence of a subscription.
Definition agent.hpp:1956
const name_for_agent_t m_name
Optional name for the agent.
Definition agent.hpp:2948
static const impl::event_handler_data_t * find_deadletter_handler(execution_demand_t &demand)
Search for event handler between deadletter handlers.
Definition agent.cpp:1627
static demand_handler_pfn_t get_demand_handler_on_message_ptr() noexcept
Definition agent.cpp:1388
bool is_agent_deactivated() const noexcept
Is agent already deactivated.
Definition agent.cpp:1753
void so_switch_to_awaiting_deregistration_state()
Switching agent to special state in case of unhandled exception.
Definition agent.cpp:756
const state_t & so_current_state() const
Access to the current agent state.
Definition agent.hpp:934
static void process_message(current_thread_id_t working_thread_id, execution_demand_t &d, thread_safety_t thread_safety, event_handler_method_t method)
Actual implementation of message handling.
Definition agent.cpp:1412
agent_ref_t create_ref()
Make an agent reference.
Definition agent.cpp:1016
void so_drop_deadletter_handler(const so_5::mbox_t &mbox)
Drops the subscription for deadletter handler.
Definition agent.hpp:2129
bool so_is_active_state(const state_t &state_to_check) const noexcept
Is a state activated?
Definition agent.cpp:713
void ensure_operation_is_on_working_thread(const char *operation_name) const
Enables operation only if it is performed on agent's working thread.
Definition agent.cpp:1485
static constexpr const state_t::history_t deep_history
Short alias for so_5::state_t::history_t::deep.
Definition agent.hpp:737
bool so_was_defined() const
Is method define_agent already called?
Definition agent.cpp:847
agent_status_t
Enumeration of possible agent statuses.
Definition agent.hpp:2785
@ defined
Agent is defined.
@ state_switch_in_progress
State switch operation is in progress.
void destroy_all_subscriptions_and_filters() noexcept
Destroy all agent's subscriptions.
Definition agent.cpp:1009
void so_create_deadletter_subscription(const mbox_t &mbox, const std::type_index &msg_type, const event_handler_method_t &method, thread_safety_t thread_safety)
Create a subscription for a deadletter handler.
Definition agent.cpp:1114
void shutdown_agent() noexcept
Agent shutdown deriver.
Definition agent.cpp:1029
void ensure_binding_finished()
Ensures that all agents from cooperation are bound to dispatchers.
Definition agent.cpp:1314
coop_t * m_agent_coop
Agent is belong to this cooperation.
Definition agent.hpp:2902
disp_binder_shptr_t so_this_agent_disp_binder() const
Returns the dispatcher binder that is used for binding this agent.
Definition agent.hpp:2671
void so_drop_subscription(const mbox_t &mbox, const state_t &target_state)
Drop subscription for the state specified.
Definition agent.hpp:1560
agent_status_t m_current_status
Current agent status.
Definition agent.hpp:2800
event_queue_t * m_event_queue
A pointer to event_queue.
Definition agent.hpp:2882
void so_set_delivery_filter(const mbox_t &mbox, Lambda &&lambda)
Set a delivery filter.
Definition agent.hpp:3410
std::enable_if< details::is_agent_method_pointer< details::method_arity::unary, Method_Pointer >::value, void >::type so_drop_subscription_for_all_states(const mbox_t &mbox, Method_Pointer)
Drop subscription for all states.
Definition agent.hpp:1716
virtual void so_define_agent()
Hook on define agent for SObjectizer.
Definition agent.cpp:841
void drop_all_delivery_filters() noexcept
Drops all delivery filters.
Definition agent.cpp:1510
disp_binder_shptr_t m_disp_binder
Binder for this agent.
Definition agent.hpp:2936
bool do_check_subscription_presence(const mbox_t &mbox, const std::type_index &msg_type, const state_t &target_state) const noexcept
Check the presence of a subscription.
Definition agent.cpp:1199
void do_state_switch(const state_t &state_to_be_set) noexcept
Actual action for switching agent state.
Definition agent.cpp:1678
std::enable_if< details::is_agent_method_pointer< details::method_arity::unary, Method_Pointer >::value, bool >::type so_has_subscription(const mbox_t &mbox, const state_t &target_state, Method_Pointer) const noexcept
Check the presence of a subscription.
Definition agent.hpp:1901
std::unique_ptr< impl::delivery_filter_storage_t > m_delivery_filters
Delivery filters for that agents.
Definition agent.hpp:2911
void so_drop_subscription_for_all_states(const mbox_t &mbox)
Drop subscription for all states.
Definition agent.hpp:1770
void return_to_default_state_if_possible() noexcept
Return agent to the default state.
Definition agent.cpp:1741
subscription_bind_t so_subscribe_self()
Initiate subscription to agent's direct mbox.
Definition agent.hpp:1416
agent_t(environment_t &env)
Constructor.
Definition agent.cpp:646
void do_set_delivery_filter(const mbox_t &mbox, const std::type_index &msg_type, delivery_filter_unique_ptr_t filter)
Set a delivery filter.
Definition agent.cpp:1520
static void call_push_event(agent_t &agent, const message_limit::control_block_t *limit, mbox_id_t mbox_id, const std::type_index &msg_type, const message_ref_t &message)
Push an event to the agent's event queue.
Definition agent.hpp:1037
mbox_t so_make_new_direct_mbox()
Create a new direct mbox for that agent.
Definition agent.cpp:768
static execution_hint_t so_create_execution_hint(execution_demand_t &demand)
Create execution hint for the specified demand.
Definition agent.cpp:901
std::enable_if< details::is_agent_method_pointer< details::method_arity::unary, Method_Pointer >::value, void >::type so_drop_subscription(const mbox_t &mbox, Method_Pointer)
Drop subscription for the default agent state.
Definition agent.hpp:1611
void so_change_state(const state_t &new_state)
Change the current state of the agent.
Definition agent.cpp:811
void push_event(const message_limit::control_block_t *limit, mbox_id_t mbox_id, const std::type_index &msg_type, const message_ref_t &message)
Push event into the event queue.
Definition agent.cpp:1265
static custom_direct_mbox_factory_t custom_direct_mbox_factory(Lambda &&lambda)
Helper for creation a custom direct mbox factory.
Definition agent.hpp:1135
coop_handle_t so_coop() const
Get a handle of agent's coop.
Definition agent.cpp:860
void so_deregister_agent_coop_normally()
A helper method for deregistering agent's coop in case of normal deregistration.
Definition agent.cpp:982
void do_drop_delivery_filter(const mbox_t &mbox, const std::type_index &msg_type) noexcept
Drop a delivery filter.
Definition agent.cpp:1548
virtual exception_reaction_t so_exception_reaction() const noexcept
A reaction from SObjectizer to an exception from agent's event.
Definition agent.cpp:746
void so_deactivate_agent()
Deactivate the agent.
Definition agent.cpp:820
disp_binder_shptr_t so_this_coop_disp_binder() const
Returns the dispatcher binder that is used as the default binder for the agent's coop.
Definition agent.cpp:988
abstract_message_sink_t & detect_sink_for_message_type(const std::type_index &msg_type)
Helper function that returns a message sink to be used for subscriptions for specified message type.
Definition agent.cpp:1153
static void demand_handler_on_message(current_thread_id_t working_thread_id, execution_demand_t &d)
Calls event handler for message.
Definition agent.cpp:1371
static constexpr const state_t::history_t shallow_history
Short alias for so_5::state_t::history_t::shallow.
Definition agent.hpp:730
virtual void so_evt_finish()
Hook of agent finish in SObjectizer.
Definition agent.cpp:707
static demand_handler_pfn_t get_demand_handler_on_finish_ptr() noexcept
Definition agent.cpp:1365
void so_add_nondestroyable_listener(agent_state_listener_t &state_listener)
Add a state listener to the agent.
Definition agent.cpp:728
static const impl::event_handler_data_t * handler_finder_msg_tracing_disabled(execution_demand_t &demand, const char *context_marker)
Handler finder for the case when message delivery tracing is disabled.
Definition agent.cpp:1559
const state_t * m_current_state_ptr
Current agent state.
Definition agent.hpp:2777
const mbox_t m_direct_mbox
A direct mbox for the agent.
Definition agent.hpp:2889
bool so_has_deadletter_handler(const so_5::mbox_t &mbox) const noexcept
Checks the presence of deadletter handler for a message of a specific type from a specific mbox.
Definition agent.hpp:2170
agent_t * self_ptr()
Definition agent.hpp:840
const priority_t m_priority
Priority of the agent.
Definition agent.hpp:2918
agent_identity_t so_agent_name() const noexcept
Get an optional name of the agent.
Definition agent.cpp:1000
static const impl::event_handler_data_t * handler_finder_msg_tracing_enabled(execution_demand_t &demand, const char *context_marker)
Handler finder for the case when message delivery tracing is enabled.
Definition agent.cpp:1572
void bind_to_coop(coop_t &coop)
Bind agent to the cooperation.
Definition agent.cpp:1023
static const impl::event_handler_data_t * find_event_handler_for_current_state(execution_demand_t &demand)
Actual search for event handler with respect to parent-child relationship between agent states.
Definition agent.cpp:1606
static void demand_handler_on_start(current_thread_id_t working_thread_id, execution_demand_t &d)
Calls so_evt_start method for agent.
Definition agent.cpp:1287
const mbox_t & so_direct_mbox() const
Get the agent's direct mbox.
Definition agent.cpp:762
impl::subscription_storage_unique_ptr_t m_subscriptions
All agent's subscriptions.
Definition agent.hpp:2830
void so_destroy_deadletter_subscription(const mbox_t &mbox, const std::type_index &msg_type)
Destroy a subscription for a deadletter handler.
Definition agent.cpp:1139
static void demand_handler_on_finish(current_thread_id_t working_thread_id, execution_demand_t &d)
Calls so_evt_finish method for agent.
Definition agent.cpp:1329
bool do_check_deadletter_presence(const mbox_t &mbox, const std::type_index &msg_type) const noexcept
Check the presence of a deadletter handler.
Definition agent.cpp:1209
void do_drop_subscription_for_all_states(const mbox_t &mbox, const std::type_index &msg_type)
Remove subscription for all states.
Definition agent.cpp:1184
agent_t(context_t ctx)
Constructor which simplifies agent construction with or without agent's tuning options.
Definition agent.cpp:659
static agent_tuning_options_t tuning_options()
Create tuning options object with default values.
Definition agent.hpp:1103
void so_add_destroyable_listener(agent_state_listener_unique_ptr_t state_listener)
Add a state listener to the agent.
Definition agent.cpp:737
environment_t & so_environment() const noexcept
Access to the SObjectizer Environment which this agent is belong.
Definition agent.cpp:853
std::enable_if< details::is_agent_method_pointer< details::method_arity::unary, Method_Pointer >::value, void >::type so_drop_subscription(const mbox_t &mbox, const state_t &target_state, Method_Pointer)
Drop subscription for the state specified.
Definition agent.hpp:1516
priority_t so_priority() const noexcept
Get the priority of the agent.
Definition agent.hpp:2555
const state_t & so_default_state() const
Access to the agent's default state.
Definition agent.cpp:775
subscription_bind_t so_subscribe(const mbox_t &mbox_ref)
Initiate subscription.
Definition agent.hpp:1359
virtual ~agent_t()
Definition agent.cpp:693
void so_bind_to_dispatcher(event_queue_t &queue) noexcept
Binding agent to the dispatcher.
Definition agent.cpp:872
void so_destroy_event_subscription(const mbox_t &mbox, const std::type_index &subscription_type, const state_t &target_state)
Destroy event subscription.
Definition agent.hpp:1461
void so_set_delivery_filter_for_mutable_msg(const mbox_t &mbox, Lambda &&lambda)
Set a delivery filter for a mutable message.
Definition agent.hpp:3433
environment_t & m_env
SObjectizer Environment for which the agent is belong.
Definition agent.hpp:2846
void so_drop_subscription(const mbox_t &mbox)
Drop subscription for the default agent state.
Definition agent.hpp:1655
void so_deregister_agent_coop(int dereg_reason)
A helper method for deregistering agent's coop.
Definition agent.cpp:975
void do_drop_subscription(const mbox_t &mbox, const std::type_index &msg_type, const state_t &target_state)
Remove subscription for the state specified.
Definition agent.cpp:1169
agent_t(environment_t &env, agent_tuning_options_t tuning_options)
Constructor which allows specification of agent's tuning options.
Definition agent.cpp:652
handler_finder_t m_handler_finder
Function for searching event handler.
Definition agent.hpp:2823
virtual void so_evt_start()
Hook on agent start inside SObjectizer.
Definition agent.cpp:701
static demand_handler_pfn_t get_demand_handler_on_enveloped_msg_ptr() noexcept
Definition agent.cpp:1406
void so_create_event_subscription(const mbox_t &mbox_ref, std::type_index type_index, const state_t &target_state, const event_handler_method_t &method, thread_safety_t thread_safety, event_handler_kind_t handler_kind)
Create a subscription for an event.
Definition agent.cpp:1083
void so_set_delivery_filter(const mbox_t &mbox, delivery_filter_unique_ptr_t filter)
Set a delivery filter.
Definition agent.hpp:2426
static void demand_handler_on_enveloped_msg(current_thread_id_t working_thread_id, execution_demand_t &d)
Handles the enveloped message.
Definition agent.cpp:1394
A collector for agent tuning options.
name_for_agent_t m_agent_name
Optional name for an agent.
so_5::priority_t query_priority() const noexcept
Get priority value.
bool m_is_user_provided_subscription_storage_factory
Does a user provide a specific subscription_storage_factory?
agent_tuning_options_t & agent_name(name_for_agent_t name)
Set a name for agent.
subscription_storage_factory_t m_subscription_storage_factory
name_for_agent_t giveout_agent_name() noexcept
Gives away the name for an agent.
friend void swap(so_5::agent_tuning_options_t &a, so_5::agent_tuning_options_t &b) noexcept
message_limit::description_container_t m_message_limits
bool has_agent_name() const noexcept
Does a name specified for an agent?
agent_tuning_options_t & custom_direct_mbox_factory(custom_direct_mbox_factory_t factory)
Set custom direct mbox factory.
const custom_direct_mbox_factory_t & query_custom_direct_mbox_factory() const noexcept
Get a reference to custom direct mbox factory.
so_5::priority_t m_priority
Priority for agent.
bool is_user_provided_subscription_storage_factory() const noexcept
Does a user provide a specific subscription_storage_factory?
static subscription_storage_factory_t default_subscription_storage_factory()
Default subscription storage factory.
const subscription_storage_factory_t & query_subscription_storage_factory() const noexcept
agent_tuning_options_t & message_limits(Args &&... args)
agent_tuning_options_t & subscription_storage_factory(subscription_storage_factory_t factory) noexcept(noexcept(std::declval< subscription_storage_factory_t & >()=std::move(factory)))
Set factory for subscription storage creation.
message_limit::description_container_t giveout_message_limits()
agent_tuning_options_t & priority(so_5::priority_t v)
Set priority for agent.
custom_direct_mbox_factory_t m_custom_direct_mbox_factory
Optional factory for custom direct mboxes.
The base class for the object with a reference counting.
atomic_refcounted_t(const atomic_refcounted_t &)=delete
unsigned long dec_ref_count() noexcept
Decrement reference count.
atomic_refcounted_t() noexcept
Default constructor.
atomic_counter_t m_ref_counter
Object reference count.
void inc_ref_count() noexcept
Increments reference count.
~atomic_refcounted_t() noexcept=default
Destructor.
atomic_refcounted_t & operator=(const atomic_refcounted_t &)=delete
Container for cooperation deregistration notificators.
Definition coop.hpp:197
std::vector< coop_dereg_notificator_t > m_notificators
Definition coop.hpp:215
void call_all(environment_t &env, const coop_handle_t &coop, const coop_dereg_reason_t &reason) const noexcept
Call all notificators.
Definition coop.cpp:38
void add(coop_dereg_notificator_t notificator)
Add a notificator.
Definition coop.hpp:201
It's a kind of strong typedef for coop's deregistration reason.
Definition coop.hpp:80
coop_dereg_reason_t(int reason) noexcept
Definition coop.hpp:86
int reason() const noexcept
Definition coop.hpp:91
coop_dereg_reason_t() noexcept
Definition coop.hpp:82
Type of smart handle for a cooperation.
friend bool operator>=(const coop_handle_t &a, const coop_handle_t &b) noexcept
static constexpr const coop_id_t invalid_coop_id
friend bool operator<(const coop_handle_t &a, const coop_handle_t &b) noexcept
bool operator!() const noexcept
Is this non-empty handle?
friend bool operator==(const coop_handle_t &a, const coop_handle_t &b) noexcept
friend bool operator!=(const coop_handle_t &a, const coop_handle_t &b) noexcept
operator bool() const noexcept
Is this handle empty?
coop_handle_t(coop_id_t id, std::shared_ptr< coop_t > coop)
Initializing constructor.
friend bool operator<=(const coop_handle_t &a, const coop_handle_t &b) noexcept
coop_id_t m_id
ID of cooperation.
auto id() const noexcept
Get the ID of the coop.
std::weak_ptr< coop_t > m_coop
Pointer for cooperation.
friend bool operator>(const coop_handle_t &a, const coop_handle_t &b) noexcept
Interface for the cooperation listener.
virtual ~coop_listener_t() noexcept=default
virtual void on_registered(environment_t &so_env, const coop_handle_t &coop) noexcept=0
Hook for the cooperation registration event.
coop_listener_t & operator=(const coop_listener_t &)=delete
coop_listener_t(coop_listener_t &&)=delete
coop_listener_t & operator=(coop_listener_t &&)=delete
coop_listener_t(const coop_listener_t &)=delete
virtual void on_deregistered(environment_t &so_env, const coop_handle_t &coop, const coop_dereg_reason_t &reason) noexcept=0
Hook for the cooperation deregistration event.
Container for cooperation registration notificators.
Definition coop.hpp:129
void call_all(environment_t &env, const coop_handle_t &coop) const noexcept
Call all notificators.
Definition coop.cpp:26
void add(coop_reg_notificator_t notificator)
Add a notificator.
Definition coop.hpp:133
std::vector< coop_reg_notificator_t > m_notificators
Definition coop.hpp:146
Agent cooperation.
Definition coop.hpp:389
coop_shptr_t m_first_child
The head of list of children coops.
Definition coop.hpp:1129
std::size_t capacity() const noexcept
Get the capacity of vector for holding agents list.
Definition coop.hpp:865
std::size_t query_agent_count() const noexcept
Get agent count in the cooperation.
Definition coop.hpp:845
environment_t & environment() const noexcept
Access to SO Environment for which cooperation is bound.
Definition coop.hpp:453
virtual ~coop_t()
Definition coop.hpp:420
registration_status_t m_registration_status
The registration status of cooperation.
Definition coop.hpp:1092
void decrement_usage_count() noexcept
Decrement usage count for the coop.
Definition coop.hpp:1224
exception_reaction_t exception_reaction() const noexcept
Get the current exception rection flag for that cooperation.
Definition coop.hpp:758
resource_deleter_vector_t m_resource_deleters
Container of user resource deleters.
Definition coop.hpp:1101
disp_binder_shptr_t m_coop_disp_binder
Default agent to the dispatcher binder.
Definition coop.hpp:1026
void add_dereg_notificator(Lambda &&notificator)
Add notificator about cooperation deregistration event.
Definition coop.hpp:678
void deregister(int reason) noexcept
Deregister the cooperation with the specified reason.
Definition coop.hpp:907
void for_each_child(Lambda &&lambda) const
A helper method for doing some actions with children coops.
Definition coop.hpp:1285
Agent * make_agent_with_binder(so_5::disp_binder_shptr_t binder, Args &&... args)
Helper method for simplification of agents creation and binding to the specified dispatcher.
Definition coop.hpp:827
exception_reaction_t m_exception_reaction
A reaction to non-handled exception.
Definition coop.hpp:1121
coop_t(const coop_t &)=delete
coop_id_t id() const noexcept
Get the ID of coop.
Definition coop.hpp:444
std::mutex m_lock
A lock for synchonization of some operations on coop.
Definition coop.hpp:1077
coop_handle_t m_parent
Parent coop.
Definition coop.hpp:1023
registration_status_t
Registration status.
Definition coop.hpp:956
@ deregistration_in_final_stage
Deregistration of the coop is in the final stage.
@ coop_registered
Cooperation is registered.
@ coop_deregistering
Cooperation is in deregistration process.
@ coop_not_registered
Cooperation is not registered yet.
std::size_t size() const noexcept
Get agent count in the cooperation.
Definition coop.hpp:857
coop_t & operator=(const coop_t &)=delete
disp_binder_shptr_t coop_disp_binder() const noexcept(noexcept(disp_binder_shptr_t{ this->m_coop_disp_binder }))
Return the default dispatcher binder for the coop.
Definition coop.hpp:1316
atomic_counter_t m_reference_count
Count for entities.
Definition coop.hpp:1043
coop_handle_t handle() noexcept
Get handle for this coop.
Definition coop.hpp:432
void set_exception_reaction(exception_reaction_t value) noexcept
Set exception reaction for that cooperation.
Definition coop.hpp:737
const coop_id_t m_id
Cooperation ID.
Definition coop.hpp:1014
void remove_child(coop_t &child) noexcept
Remove a child from the parent coop.
Definition coop.hpp:1267
Agent * add_agent(std::unique_ptr< Agent > agent, disp_binder_shptr_t disp_binder)
Add agent to the cooperation with the dispatcher binding.
Definition coop.hpp:503
void deregister_normally() noexcept
Deregistr the cooperation normally.
Definition coop.hpp:941
coop_t(coop_id_t id, coop_handle_t parent, disp_binder_shptr_t coop_disp_binder, outliving_reference_t< environment_t > env)
Constructor.
Definition coop.hpp:404
void reserve(std::size_t v)
Reserve a space for vector for holding agents list.
Definition coop.hpp:883
coop_dereg_reason_t m_dereg_reason
Deregistration reason.
Definition coop.hpp:1110
void increment_usage_count() noexcept
Increment usage count for the coop.
Definition coop.hpp:1196
coop_shptr_t m_next_in_final_dereg_chain
The next coop in the chain for final deregistration actions.
Definition coop.hpp:1169
Agent * make_agent(Args &&... args)
Helper method for simplification of agents creation.
Definition coop.hpp:792
coop_reg_notificators_container_ref_t m_reg_notificators
Notificators for registration event.
Definition coop.hpp:1050
void add_reg_notificator(Lambda &&notificator)
Add notificator about cooperation registration event.
Definition coop.hpp:589
coop_shptr_t m_prev_sibling
The previous coop in sibling's chain.
Definition coop.hpp:1141
coop_t(coop_t &&)=delete
void add_child(coop_shptr_t child)
Add a new child to the parent coop.
Definition coop.hpp:1242
agent_array_t m_agent_array
Cooperation agents.
Definition coop.hpp:1029
Agent * add_agent(std::unique_ptr< Agent > agent)
Add agent to cooperation.
Definition coop.hpp:466
outliving_reference_t< environment_t > m_env
SObjectizer Environment for which cooperation is created.
Definition coop.hpp:1032
T * take_under_control(std::unique_ptr< T > resource)
Take a user resouce under cooperation control.
Definition coop.hpp:710
coop_dereg_notificators_container_ref_t m_dereg_notificators
Notificators for deregistration event.
Definition coop.hpp:1057
coop_t & operator=(coop_t &&)=delete
coop_shptr_t m_next_sibling
The next coop in sibling's chain.
Definition coop.hpp:1153
A special type that plays role of unique_ptr for coop.
Definition coop.hpp:1342
coop_unique_holder_t(coop_unique_holder_t &&)=default
coop_unique_holder_t & operator=(const coop_unique_holder_t &)=delete
coop_shptr_t m_coop
A pointer to coop object.
Definition coop.hpp:1346
bool operator!() const noexcept
Definition coop.hpp:1376
operator bool() const noexcept
Definition coop.hpp:1374
coop_unique_holder_t & operator=(coop_unique_holder_t &&) noexcept=default
friend void swap(coop_unique_holder_t &a, coop_unique_holder_t &b) noexcept
Definition coop.hpp:1368
coop_unique_holder_t(coop_shptr_t coop)
Definition coop.hpp:1356
coop_t & operator*() const noexcept
Definition coop.hpp:1385
coop_shptr_t release() noexcept
Definition coop.hpp:1349
coop_t * get() const noexcept
Definition coop.hpp:1379
coop_t * operator->() const noexcept
Definition coop.hpp:1382
coop_unique_holder_t(const coop_unique_holder_t &)=delete
Interface for creator of new mbox in OOP style.
virtual mbox_t create(const mbox_creation_data_t &data)=0
Creation of custom mbox.
Template-based implementation of creator interface.
virtual mbox_t create(const mbox_creation_data_t &data) override
Creation of custom mbox.
Lambda m_lambda
Lambda or functional object to be used for custom mbox creation.
An interface of delivery filter object.
Definition mbox.hpp:62
delivery_filter_t(delivery_filter_t &&)=delete
virtual bool check(const abstract_message_sink_t &receiver, message_t &msg) const noexcept=0
Checker for a message instance.
delivery_filter_t & operator=(delivery_filter_t &&)=delete
delivery_filter_t(const delivery_filter_t &)=delete
virtual ~delivery_filter_t() noexcept=default
delivery_filter_t & operator=(const delivery_filter_t &)=delete
bool handle(const std::type_index &, message_ref_t &) const
Template class for storing bunch of message handlers.
bool handle(const std::type_index &msg_type, message_ref_t &message) const
Find handler for a message and execute it.
msg_type_and_handler_pair_t m_handlers[N]
Vector of message handlers.
void prepare()
Prepare bunch to use with actual messages.
void add_handler(std::size_t index, msg_type_and_handler_pair_t &&handler)
Add another handler to the specified index.
Helper class for building and registering new cooperation.
decltype(auto) build_and_register_coop(disp_binder_shptr_t binder, Lambda &&lambda)
introduce_coop_helper_t(environment_t &env)
Constructor for the case of creation a cooperation without parent.
coop_handle_t m_parent
Optional parent coop.
introduce_coop_helper_t(environment_t &env, coop_handle_t parent)
Constructor for the case of creation a cooperation with parent.
decltype(auto) introduce(disp_binder_shptr_t binder, L &&lambda)
environment_t & m_env
Environment for creation of cooperation.
decltype(auto) introduce(L &&lambda)
basic_message_holder_impl_t(intrusive_ptr_t< Envelope > msg) noexcept
operator bool() const noexcept
Check for the non-emptiness of message_holder.
bool operator!() const noexcept
Check for the emptiness of message_holder.
bool empty() const noexcept
Check for the emptiness of message_holder.
void reset() noexcept
Drops to pointer to the message instance.
An of mixin with getters for message_holder.
Return_Type & operator*() const noexcept
Get a reference to the message inside message_holder.
Return_Type * get() const noexcept
Get a pointer to the message inside message_holder.
Return_Type * operator->() const noexcept
Get a pointer to the message inside message_holder.
A part of implementation of message_holder to be used for shared ownership of message instances.
intrusive_ptr_t< Envelope > make_reference() const noexcept
Make an another reference to the message.
A part of implementation of message_holder to be used for unique ownership of message instances.
unique_message_holder_impl_t(const unique_message_holder_impl_t &)=delete
unique_message_holder_impl_t & operator=(const unique_message_holder_impl_t &)=delete
intrusive_ptr_t< Envelope > make_reference() noexcept
Extracts the smart pointer to the message.
unique_message_holder_impl_t & operator=(unique_message_holder_impl_t &&) noexcept=default
unique_message_holder_impl_t(unique_message_holder_impl_t &&)=default
message_holder_t< M, Ownership > make_holder() noexcept
Create a holder for this message.
Definition mhood.hpp:197
intrusive_ptr_t< envelope_type > make_reference() noexcept
Create a smart pointer for the message envelope.
Definition mhood.hpp:181
message_holder_t< M, Ownership > make_holder() const noexcept
Create a holder for this message.
Definition mhood.hpp:101
intrusive_ptr_t< envelope_type > make_reference() const noexcept
Create a smart pointer for the message envelope.
Definition mhood.hpp:87
const payload_type * operator->() const noexcept
Access to the message via pointer.
Definition mhood.hpp:112
intrusive_ptr_t< envelope_type > make_reference() noexcept
Create a smart pointer for the message envelope.
Definition mhood.hpp:380
message_holder_t< M, Ownership > make_holder() noexcept
Create a holder for this message.
Definition mhood.hpp:399
message_holder_t< M, Ownership > make_holder() const noexcept
Create a holder for this message.
Definition mhood.hpp:299
const payload_type * operator->() const noexcept
Access to the message via pointer.
Definition mhood.hpp:310
intrusive_ptr_t< envelope_type > make_reference() const noexcept
Create a smart pointer for the message envelope.
Definition mhood.hpp:285
A type to be used as a base for mhood_t implementation.
Definition mhood.hpp:52
Helper class for calculating remaining time.
Helper template class for do rollback actions automatically in the destructor.
Helper class for scope exit implementation.
An interface of factory for management of worker threads.
abstract_work_thread_factory_t & operator=(const abstract_work_thread_factory_t &)=delete
virtual abstract_work_thread_t & acquire(so_5::environment_t &env)=0
Get a new worker thread from factory.
abstract_work_thread_factory_t & operator=(abstract_work_thread_factory_t &&)=delete
abstract_work_thread_factory_t(const abstract_work_thread_factory_t &)=delete
abstract_work_thread_factory_t(abstract_work_thread_factory_t &&)=delete
virtual void release(abstract_work_thread_t &thread) noexcept=0
Return a worker thread back to the factory.
An interface for one worker thread.
abstract_work_thread_t(abstract_work_thread_t &&)=delete
abstract_work_thread_t(const abstract_work_thread_t &)=delete
virtual void join()=0
Stops the current thread until worker thread completes execution of thread_body passed to previous ca...
abstract_work_thread_t & operator=(const abstract_work_thread_t &)=delete
abstract_work_thread_t & operator=(abstract_work_thread_t &&)=delete
virtual void start(body_func_t thread_body)=0
Start a new thread and execute specified functor on it.
An interface for somethine like condition variable for waiting on MPMC queue lock.
virtual void notify() noexcept=0
Notification for waiting customer.
condition_t(const condition_t &)=delete
virtual ~condition_t() noexcept=default
condition_t & operator=(const condition_t &)=delete
virtual void wait() noexcept=0
Waiting on condition.
condition_t & operator=(condition_t &&)=delete
An interface for lock for MPMC queue.
lock_t & operator=(const lock_t &)=delete
virtual void unlock() noexcept=0
Unlock object locked in exclusive mode.
virtual void lock() noexcept=0
Lock object in exclusive mode.
virtual condition_unique_ptr_t allocate_condition()=0
Create condition object for another MPMC queue's customer.
lock_t & operator=(lock_t &&)=delete
virtual ~lock_t() noexcept=default
Container for storing parameters for MPMC queue.
queue_params_t & operator=(queue_params_t &&o) noexcept
Move operator.
queue_params_t & lock_factory(lock_factory_t factory)
Setter for lock factory.
queue_params_t(const queue_params_t &o)
Copy constructor.
lock_factory_t m_lock_factory
Lock factory to be used during queue creation.
queue_params_t & operator=(const queue_params_t &o)
Copy operator.
friend void swap(queue_params_t &a, queue_params_t &b) noexcept
std::size_t m_next_thread_wakeup_threshold
Threshold for wake up next working thread if there are non-empty queues.
queue_params_t(queue_params_t &&o)
Move constructor.
std::size_t next_thread_wakeup_threshold() const
Getter for thread wakeup threshold value.
queue_params_t & next_thread_wakeup_threshold(std::size_t value)
Setter for thread wakeup threshold.
const lock_factory_t & lock_factory() const
Getter for lock factory.
An analog of std::lock_guard for MPSC queue lock.
lock_guard_t(const lock_guard_t &)=delete
An interface for lock for MPSC queue.
virtual void unlock() noexcept=0
Unlock object locked in exclusive mode.
virtual void notify_one() noexcept=0
Notify one waiting thread if it exists.
virtual void wait_for_notify() noexcept=0
Waiting for nofication.
lock_t & operator=(lock_t &&)=delete
lock_t & operator=(const lock_t &)=delete
virtual void lock() noexcept=0
Lock object in exclusive mode.
virtual ~lock_t() noexcept=default
Container for storing parameters for MPSC queue.
queue_params_t(const queue_params_t &o)
Copy constructor.
const lock_factory_t & lock_factory() const
Getter for lock factory.
queue_params_t(queue_params_t &&o) noexcept
Move constructor.
queue_params_t & lock_factory(lock_factory_t factory)
Setter for lock factory.
queue_params_t & operator=(queue_params_t &&o) noexcept
Move operator.
friend void swap(queue_params_t &a, queue_params_t &b) noexcept
queue_params_t & operator=(const queue_params_t &o)
Copy operator.
lock_factory_t m_lock_factory
Lock factory to be used during queue creation.
An analog of std::unique_lock for MPSC queue lock.
unique_lock_t(const unique_lock_t &)=delete
Alias for namespace with traits of event queue.
disp_params_t & set_queue_params(queue_traits::queue_params_t p)
Setter for queue parameters.
const queue_traits::queue_params_t & queue_params() const noexcept
Getter for queue parameters.
disp_params_t()=default
Default constructor.
disp_params_t & tune_queue_params(L tunner)
Tuner for queue parameters.
queue_traits::queue_params_t m_queue_params
Queue parameters.
friend void swap(disp_params_t &a, disp_params_t &b) noexcept
Alias for namespace with traits of event queue.
disp_params_t & tune_queue_params(L tunner)
Tuner for queue parameters.
disp_params_t()=default
Default constructor.
disp_params_t & set_queue_params(queue_traits::queue_params_t p)
Setter for queue parameters.
const queue_traits::queue_params_t & queue_params() const
Getter for queue parameters.
friend void swap(disp_params_t &a, disp_params_t &b) noexcept
queue_traits::queue_params_t m_queue_params
Queue parameters.
Params & work_thread_activity_tracking(work_thread_activity_tracking_t v) noexcept
Setter for work thread activity tracking.
friend void swap(work_thread_activity_tracking_flag_mixin_t &a, work_thread_activity_tracking_flag_mixin_t &b) noexcept
Params & turn_work_thread_activity_tracking_on() noexcept
Helper for turning work thread activity tracking on.
Params & turn_work_thread_activity_tracking_off() noexcept
Helper for turning work thread activity tracking off.
work_thread_activity_tracking_t work_thread_activity_tracking() const noexcept
Getter for work thread activity tracking.
Mixin that holds optional work thread factory.
abstract_work_thread_factory_shptr_t work_thread_factory() const noexcept
Getter for work thread factory.
friend void swap(work_thread_factory_mixin_t &a, work_thread_factory_mixin_t &b) noexcept
Params & work_thread_factory(abstract_work_thread_factory_shptr_t v) noexcept
Setter for work thread factory.
An analog of unique_ptr for abstract_work_thread.
abstract_work_thread_t & unchecked_get() const noexcept
Unsafe method for getting a reference to holding abstract_work_thread instance.
work_thread_holder_t(work_thread_holder_t &&o) noexcept
abstract_work_thread_factory_shptr_t m_factory
work_thread_holder_t & operator=(const work_thread_holder_t &)=delete
work_thread_holder_t(abstract_work_thread_t &thread, abstract_work_thread_factory_shptr_t factory) noexcept
work_thread_holder_t & operator=(work_thread_holder_t &&o) noexcept
work_thread_holder_t(const work_thread_holder_t &)=delete
friend void swap(work_thread_holder_t &a, work_thread_holder_t &b) noexcept
work_thread_holder_t() noexcept=default
Interface for dispatcher binders.
disp_binder_t(const disp_binder_t &)=delete
virtual void bind(agent_t &agent) noexcept=0
Bind agent to dispatcher.
virtual void unbind(agent_t &agent) noexcept=0
Unbind agent from dispatcher.
disp_binder_t & operator=(const disp_binder_t &)=delete
disp_binder_t(disp_binder_t &&)=delete
virtual void preallocate_resources(agent_t &agent)=0
Allocate resources in dispatcher for new agent.
disp_binder_t()=default
disp_binder_t & operator=(disp_binder_t &&)=delete
virtual void undo_preallocation(agent_t &agent) noexcept=0
Undo resources allocation.
virtual ~disp_binder_t() noexcept=default
An interface of envelope with some message/signal inside.
virtual ~envelope_t() override=default
envelope_t(const envelope_t &)=default
envelope_t & operator=(envelope_t &&) noexcept=default
envelope_t & operator=(const envelope_t &)=default
kind_t so5_message_kind() const noexcept override
Detect the kind of the message.
virtual void access_hook(access_context_t context, handler_invoker_t &invoker) noexcept=0
envelope_t(envelope_t &&)=default
An extended version of handling_context which can be used for calling event handler.
handler_invoker_t(const handler_invoker_t &)=default
handler_invoker_t(handler_invoker_t &&)=default
handler_invoker_t & operator=(const handler_invoker_t &)=default
handler_invoker_t & operator=(handler_invoker_t &&) noexcept=default
virtual void invoke(const payload_info_t &payload) noexcept=0
Call an actual handler for the enveloped message/signal.
An implementation of handler_invoker interface.
agent_demand_handler_invoker_t(current_thread_id_t work_thread_id, execution_demand_t &demand, const so_5::impl::event_handler_data_t &handler_data)
Initializing constructor.
An information about payload inside envelope.
message_ref_t m_message
Actual enveloped message.
message_ref_t & message() const noexcept
payload_info_t(message_ref_t message)
Initializing constructor.
An interface for environment_infrastructure entity.
environment_infrastructure_t(const environment_infrastructure_t &)=delete
virtual::so_5::stats::repository_t & stats_repository() noexcept=0
Get stats repository for the environment.
virtual ~environment_infrastructure_t() noexcept=default
virtual coop_unique_holder_t make_coop(coop_handle_t parent, disp_binder_shptr_t default_binder)=0
Create an instance of a new coop.
virtual bool final_deregister_coop(coop_shptr_t coop) noexcept=0
Do final actions of the cooperation deregistration.
virtual void launch(env_init_t init_fn)=0
Do actual launch of SObjectizer's Environment.
virtual void ready_to_deregister_notify(coop_shptr_t coop) noexcept=0
virtual::so_5::stats::controller_t & stats_controller() noexcept=0
Get stats controller for the environment.
virtual so_5::timer_id_t schedule_timer(const std::type_index &type_wrapper, const message_ref_t &msg, const mbox_t &mbox, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period)=0
Initiate a timer (delayed or periodic message).
virtual void stop() noexcept=0
Initiate a signal for shutdown of Environment.
static environment_infrastructure_deleter_fnptr_t default_deleter()
Default deleter for environment_infrastructure object.
virtual coop_handle_t register_coop(coop_unique_holder_t coop)=0
Register new cooperation.
environment_infrastructure_t(environment_infrastructure_t &&)=delete
virtual disp_binder_shptr_t make_default_disp_binder()=0
Create a binder for the default dispatcher.
virtual void single_timer(const std::type_index &type_wrapper, const message_ref_t &msg, const mbox_t &mbox, std::chrono::steady_clock::duration pause)=0
Initiate a delayed message.
environment_infrastructure_t & operator=(const environment_infrastructure_t &)=delete
virtual timer_thread_stats_t query_timer_thread_stats()=0
Query run-time statistics for timer (thread or manager).
virtual coop_repository_stats_t query_coop_repository_stats()=0
Query run-time statistics for cooperation repository.
environment_infrastructure_t & operator=(environment_infrastructure_t &&)=delete
Parameters for the SObjectizer Environment initialization.
event_queue_hook_unique_ptr_t m_event_queue_hook
An event_queue_hook object.
layer_map_t m_so_layers
Additional layers.
so_5::disp::abstract_work_thread_factory_shptr_t so5_giveout_work_thread_factory()
Take out work_thread_factory object.
environment_infrastructure_factory_t m_infrastructure_factory
A factory for environment infrastructure entity.
environment_params_t & event_exception_logger(event_exception_logger_unique_ptr_t logger)
Set exception logger object.
bool m_autoshutdown_disabled
Is autoshutdown when there is no more cooperation disabled?
queue_locks_defaults_manager_unique_ptr_t so5_giveout_queue_locks_defaults_manager()
Take out queue locks defaults manager.
environment_params_t & default_subscription_storage_factory(subscription_storage_factory_t factory)
Set subscription storage factory to be used by default.
environment_params_t & infrastructure_factory(environment_infrastructure_factory_t factory)
Set new environment infrastructure factory.
environment_params_t & work_thread_factory(so_5::disp::abstract_work_thread_factory_shptr_t factory)
Set work thread factory to be used by default.
environment_params_t & default_disp_params(so_5::disp::nef_one_thread::disp_params_t params)
Set parameters for a case when nef_one_thread-disp must be used as the default dispatcher.
default_disp_params_t m_default_disp_params
Parameters for the default dispatcher.
void add_layer(const std::type_index &type, layer_unique_ptr_t layer_ptr)
Add an additional layer.
bool autoshutdown_disabled() const
Is autoshutdown disabled?
coop_listener_unique_ptr_t so5_giveout_coop_listener()
Get cooperation listener.
environment_params_t & turn_work_thread_activity_tracking_off()
Helper for turning work thread activity tracking off.
environment_params_t & disable_autoshutdown()
Do not shutdown SO Environment when it is becomes empty.
so_5::msg_tracing::tracer_unique_ptr_t so5_giveout_message_delivery_tracer()
Get message delivery tracer for the environment.
environment_params_t & message_delivery_tracer(so_5::msg_tracing::tracer_unique_ptr_t tracer)
Set message delivery tracer for the environment.
environment_params_t & queue_locks_defaults_manager(queue_locks_defaults_manager_unique_ptr_t manager)
Set manager for queue locks defaults.
environment_params_t & error_logger(error_logger_shptr_t logger)
Set error logger for the environment.
environment_params_t & default_disp_params(so_5::disp::one_thread::disp_params_t params)
Set parameters for a case when one_thread-disp must be used as the default dispatcher.
environment_params_t & work_thread_activity_tracking(work_thread_activity_tracking_t flag)
Set activity tracking flag for the whole SObjectizer Environment.
void event_queue_hook(event_queue_hook_unique_ptr_t hook)
Set event_queue_hook object.
environment_params_t & add_layer(std::unique_ptr< SO_Layer > layer_ptr)
Add an additional layer to the SObjectizer Environment.
so_5::msg_tracing::filter_shptr_t so5_giveout_message_delivery_tracer_filter()
Get message delivery tracer filter for the environment.
queue_locks_defaults_manager_unique_ptr_t m_queue_locks_defaults_manager
Manager for defaults of queue locks.
environment_params_t(environment_params_t &&other)
Move constructor.
so_5::timer_thread_factory_t so5_giveout_timer_thread_factory()
Get the timer_thread factory.
const environment_infrastructure_factory_t & infrastructure_factory() const
Get the current environment infrastructure factory.
friend SO_5_FUNC void swap(environment_params_t &a, environment_params_t &b) noexcept
Swap operation.
environment_params_t & coop_listener(coop_listener_unique_ptr_t coop_listener)
Set cooperation listener object.
environment_params_t & turn_work_thread_activity_tracking_on()
Helper for turning work thread activity tracking on.
layer_map_t so5_giveout_layers_map()
Get map of default SObjectizer's layers.
so_5::msg_tracing::tracer_unique_ptr_t m_message_delivery_tracer
Tracer for message delivery.
exception_reaction_t exception_reaction() const noexcept
Get exception reaction flag value.
error_logger_shptr_t m_error_logger
Error logger for the environment.
environment_params_t & message_delivery_tracer_filter(so_5::msg_tracing::filter_shptr_t filter)
Set message tracer filter for the environment.
environment_params_t & exception_reaction(exception_reaction_t value) noexcept
Set exception reaction flag value.
subscription_storage_factory_t m_default_subscription_storage_factory
Default subscription storage factory.
const default_disp_params_t & default_disp_params() const
Get the parameters for the default dispatcher.
so_5::disp::abstract_work_thread_factory_shptr_t m_work_thread_factory
Global factory for work threads.
environment_params_t()
Constructor.
event_exception_logger_unique_ptr_t m_event_exception_logger
Exception logger.
event_queue_hook_unique_ptr_t so5_giveout_event_queue_hook()
Take out event_queue_hook object.
so_5::msg_tracing::filter_shptr_t m_message_delivery_tracer_filter
Message delivery tracer filter to be used with environment.
work_thread_activity_tracking_t work_thread_activity_tracking() const
Get activity tracking flag for the whole SObjectizer Environment.
const error_logger_shptr_t & so5_error_logger() const
Get error logger for the environment.
environment_params_t & operator=(environment_params_t &&other) noexcept
Move operator.
event_exception_logger_unique_ptr_t so5_giveout_event_exception_logger()
Get exception logger.
coop_listener_unique_ptr_t m_coop_listener
Cooperation listener.
environment_params_t & timer_thread(so_5::timer_thread_factory_t factory)
Set the timer_thread factory.
exception_reaction_t m_exception_reaction
Exception reaction flag for the whole SO Environment.
work_thread_activity_tracking_t m_work_thread_activity_tracking
Work thread activity tracking for the whole Environment.
const subscription_storage_factory_t & default_subscription_storage_factory() const noexcept
Get the current default subscription storage factory.
so_5::timer_thread_factory_t m_timer_thread_factory
Timer thread factory.
SObjectizer Environment.
disp_binder_shptr_t so_make_default_disp_binder()
Get binding to the default dispatcher.
mbox_t create_mbox()
Create an anonymous MPMC mbox.
error_logger_t & error_logger() const
Get the error_logger object.
void imp_run_layers_and_go_further()
Run layers and call next run stage.
void add_extra_layer(const std::type_index &type, const layer_ref_t &layer)
Add an additional layer.
so_5::timer_id_t so_schedule_timer(const low_level_api::schedule_timer_params_t params)
Schedule timer event.
stats::repository_t & stats_repository()
Access to repository of data sources for run-time monitoring.
void add_extra_layer(std::unique_ptr< SO_Layer > layer_ptr)
Add an additional layer.
void change_message_delivery_tracer_filter(so_5::msg_tracing::filter_shptr_t filter)
Change the current msg_tracing's filter to a new one.
coop_handle_t register_agent_as_coop(std::unique_ptr< A > agent)
Register single agent as a cooperation.
void install_exception_logger(event_exception_logger_unique_ptr_t logger)
Set up an exception logger.
mbox_t introduce_named_mbox(mbox_namespace_name_t mbox_namespace, nonempty_name_t mbox_name, const std::function< mbox_t() > &mbox_factory)
Introduce named mbox with user-provided factory.
SO_Layer * query_layer_noexcept() const
void run()
Run the SObjectizer Run-Time.
environment_t & operator=(const environment_t &)=delete
void remove_extra_layer(const std::type_index &type)
Remove an additional layer.
mchain_t create_mchain(const mchain_params_t &params)
Create message chain.
exception_reaction_t exception_reaction() const noexcept
An exception reaction for the whole SO Environment.
std::unique_ptr< internals_t > m_impl
SObjectizer Environment internals.
environment_t & self_ref()
Auxiliary methods for getting reference to itself.
std::unique_ptr< Agent > make_agent(Args &&... args)
Helper method for simplification of agents creation.
coop_handle_t register_agent_as_coop(std::unique_ptr< A > agent, disp_binder_shptr_t disp_binder)
Register single agent as a cooperation with specified dispatcher binder.
coop_unique_holder_t make_coop(coop_handle_t parent)
Create a new cooperation that will be a child for specified parent coop.
so_5::disp::abstract_work_thread_factory_shptr_t work_thread_factory() const noexcept
Access to the global work thread factory.
void call_exception_logger(const std::exception &event_exception, const coop_handle_t &coop) noexcept
Call event exception logger for logging an exception.
environment_t(environment_params_t &&so_environment_params)
stats::controller_t & stats_controller()
Access to controller of run-time monitoring.
layer_t * query_layer(const std::type_index &type) const
Access to an additional layer.
mbox_t make_custom_mbox(Lambda &&lambda)
Create a custom mbox.
void imp_run_infrastructure()
Launch environment infrastructure and wait for finish.
void imp_run_stats_controller_and_go_further()
Run controller for run-time monitoring and call next run stage.
coop_unique_holder_t make_coop()
Create a cooperation.
void stop() noexcept
Send a shutdown signal to the Run-Time.
work_thread_activity_tracking_t work_thread_activity_tracking() const
Get activity tracking flag for the whole SObjectizer Environment.
decltype(auto) introduce_coop(Args &&... args)
Helper method for simplification of cooperation creation and registration.
mbox_t do_make_custom_mbox(custom_mbox_details::creator_iface_t &creator)
Actual creation of a custom mbox.
void remove_stop_guard(stop_guard_shptr_t guard)
Remove stop_guard and complete the stop operation if necessary.
environment_t(const environment_t &)=delete
coop_handle_t register_coop(coop_unique_holder_t agent_coop)
Register a cooperation.
void deregister_coop(coop_handle_t coop, int reason) noexcept
Deregister the cooperation.
SO_Layer * query_layer() const
Get access to the layer with exception if layer is not found.
coop_unique_holder_t make_coop(disp_binder_shptr_t disp_binder)
Create a cooperation with specified dispatcher binder.
virtual void init()=0
Initialization hook.
mbox_t create_mbox(nonempty_name_t mbox_name)
Create named MPMC mbox.
void so_single_timer(const low_level_api::single_timer_params_t params)
Schedule a single shot timer event.
stop_guard_t::setup_result_t setup_stop_guard(stop_guard_shptr_t guard, stop_guard_t::what_if_stop_in_progress_t reaction_on_stop_in_progress=stop_guard_t::what_if_stop_in_progress_t::throw_exception)
Set up a new stop_guard.
bool autoshutdown_disabled() const
Get autoshutdown_disabled flag.
coop_unique_holder_t make_coop(coop_handle_t parent, disp_binder_shptr_t disp_binder)
Create a new cooperation that will be a child for specified parent coop.
An interface for logging error messages.
error_logger_t & operator=(error_logger_t &)=delete
virtual ~error_logger_t() noexcept=default
error_logger_t(const error_logger_t &)=delete
error_logger_t()=default
virtual void log(const char *file_name, unsigned int line, const std::string &message)=0
A method for logging message.
An interface for the exception logging.
event_exception_logger_t & operator=(const event_exception_logger_t &)=delete
virtual void on_install(event_exception_logger_unique_ptr_t previous_logger) noexcept
Installation hook.
event_exception_logger_t & operator=(event_exception_logger_t &&)=delete
event_exception_logger_t(const event_exception_logger_t &)=delete
virtual void log_exception(const std::exception &event_exception, const coop_handle_t &coop) noexcept=0
Log the exception caught.
event_exception_logger_t(event_exception_logger_t &&)=delete
virtual ~event_exception_logger_t() noexcept=default
Interface of event_queue_hook object.
virtual event_queue_t * on_bind(agent_t *agent, event_queue_t *original_queue) noexcept=0
A reaction to binding of an agent to some event_queue.
static void default_deleter(event_queue_hook_t *what) noexcept
An implementation of deleter that use operator delete for destroying object of type event_queue_hook.
event_queue_hook_t & operator=(const event_queue_hook_t &)=delete
event_queue_hook_t(event_queue_hook_t &&)=delete
event_queue_hook_t(const event_queue_hook_t &)=delete
event_queue_hook_t & operator=(event_queue_hook_t &&)=delete
static void noop_deleter(event_queue_hook_t *) noexcept
An implementation of no-op deleter.
virtual ~event_queue_hook_t()=default
virtual void on_unbind(agent_t *agent, event_queue_t *queue) noexcept=0
A reaction to unbinding of an agent from some event_queue.
An interface of event queue for agent.
event_queue_t & operator=(const event_queue_t &)=delete
event_queue_t & operator=(event_queue_t &&)=delete
virtual void push(execution_demand_t demand)=0
Enqueue new event to the queue.
virtual ~event_queue_t() noexcept=default
virtual void push_evt_finish(execution_demand_t demand) noexcept=0
Enqueue a demand for evt_finish event.
virtual void push_evt_start(execution_demand_t demand)=0
Enqueue a demand for evt_start event.
event_queue_t(event_queue_t &&)=delete
event_queue_t()=default
event_queue_t(const event_queue_t &)=delete
The base class for all SObjectizer exceptions.
Definition exception.hpp:34
int error_code() const noexcept
Error code getter.
Definition exception.hpp:53
exception_t(const exception_t &)=default
exception_t(exception_t &&)=default
int m_error_code
Error code.
Definition exception.hpp:64
exception_t(const std::string &error_descr, int error_code)
Definition exception.hpp:36
exception_t & operator=(exception_t &&o) noexcept=default
exception_t & operator=(exception_t &o)=default
static void raise(const char *file_name, unsigned int line_number, std::string_view error_descr, int error_code)
Definition exception.cpp:17
A hint for a dispatcher for execution of event for the concrete execution_demand.
bool is_thread_safe() const
Is thread safe handler?
execution_hint_t(execution_demand_t &demand)
execution_hint_t(execution_demand_t &demand, direct_func_t direct_func, thread_safety_t thread_safety)
Initializing constructor.
thread_safety_t m_thread_safety
Thread safety for event handler.
void exec(current_thread_id_t working_thread_id) const
Call event handler directly.
direct_func_t m_direct_func
Function for call event handler directly.
static execution_hint_t create_empty_execution_hint(execution_demand_t &demand)
execution_demand_t & m_demand
A reference to demand for which that hint has been created.
A helper for coop's deregistration procedure.
Definition coop.cpp:415
An internal class with real implementation of coop's logic.
Definition coop.hpp:249
static void destroy_content(coop_t &coop) noexcept
Perform all necessary cleanup actions for coop.
Definition coop.cpp:54
static void do_add_agent(coop_t &coop, agent_ref_t agent_ref, disp_binder_shptr_t disp_binder)
Add agent to the cooperation with the dispatcher binding.
Definition coop.cpp:95
static void do_final_deregistration_actions(coop_t &coop)
Perform final deregistration actions for an coop.
Definition coop.cpp:501
static void do_add_child(coop_t &parent, coop_shptr_t child)
Perform addition of a new child coop.
Definition coop.cpp:521
static void add_dereg_notificator(coop_t &coop, coop_dereg_notificator_t notificator)
Add notificator about cooperation deregistration event.
Definition coop.cpp:146
static exception_reaction_t exception_reaction(const coop_t &coop) noexcept
Get exception reaction for coop.
Definition coop.cpp:157
static void do_remove_child(coop_t &parent, coop_t &child) noexcept
Perform removement of a child coop.
Definition coop.cpp:560
static void add_reg_notificator(coop_t &coop, coop_reg_notificator_t notificator)
Add notificator about cooperation registration event.
Definition coop.cpp:136
static void do_decrement_reference_count(coop_t &coop) noexcept
Do decrement reference count for a coop.
Definition coop.cpp:174
static void do_deregistration_specific_actions(coop_t &coop, coop_dereg_reason_t reason) noexcept
Perform actions related to the deregistration of coop.
Definition coop.cpp:493
static void do_registration_specific_actions(coop_t &coop)
Perform actions related to the registration of coop.
Definition coop.cpp:405
static void do_add_agent(coop_t &coop, agent_ref_t agent_ref)
Add agent to cooperation.
Definition coop.cpp:79
A special class for accessing private members of agent_coop.
static coop_unique_holder_t make_coop(coop_id_t id, coop_handle_t parent, disp_binder_shptr_t default_binder, outliving_reference_t< environment_t > env)
static void set_next_in_final_dereg_chain(coop_t &coop, coop_shptr_t next_in_chain) noexcept
Set the next coop in the chain of coops for the final deregistration.
static coop_reg_notificators_container_ref_t giveout_reg_notificators(coop_t &coop) noexcept
static void do_final_deregistration_actions(coop_t &coop)
static coop_dereg_reason_t dereg_reason(const coop_t &coop) noexcept
static coop_shptr_t giveout_next_in_final_dereg_chain(coop_t &coop) noexcept
Extract a smart pointer to the next coop in the chain of coops for the final deregistration.
static void decrement_usage_count(coop_t &coop)
static void destroy_content(coop_t &coop)
static coop_dereg_notificators_container_ref_t giveout_dereg_notificators(coop_t &coop) noexcept
static void increment_usage_count(coop_t &coop) noexcept
static void do_registration_specific_actions(coop_t &coop)
static coop_shptr_t make_from(coop_unique_holder_t holder) noexcept
Storage for message delivery filters.
void drop_all() noexcept
Drop all defined filters.
map_t m_filters
Information about defined filters.
void set_delivery_filter(const mbox_t &mbox, const std::type_index &msg_type, delivery_filter_unique_ptr_t filter, so_5::outliving_reference_t< abstract_message_sink_t > owner)
Set a delivery filter.
void drop_delivery_filter(const mbox_t &mbox, const std::type_index &msg_type) noexcept
Remove delivery filter.
message_sinks_with_limits_holder_t m_holder
All sinks.
fixed_sinks_storage_t(partially_constructed_agent_ptr_t owner_ptr, so_5::message_limit::description_container_t &&descriptions)
Initializing constructor.
abstract_message_sink_t * find_or_create(const std::type_index &msg_type) override
growable_sinks_storage_t(partially_constructed_agent_ptr_t owner_ptr, so_5::message_limit::description_t &&default_limit_description, so_5::message_limit::description_container_t &&descriptions)
Initializing constructor.
const so_5::message_limit::description_t m_default_limit_description
Description of the default limit.
abstract_message_sink_t * find_or_create(const std::type_index &msg_type) override
message_sinks_with_limits_holder_t m_holder
All sinks and limits.
const partially_constructed_agent_ptr_t m_owner_ptr
Owner of sinks and limits.
A helper class for accessing the functionality of environment-class which is specific for SObjectizer...
mbox_id_t allocate_mbox_id() noexcept
Allocate a new ID for a new custom mbox or mchain.
event_queue_t * event_queue_on_bind(agent_t *agent, event_queue_t *original_queue) noexcept
Call the event_queue_hook when an agent is being bound to a particular event_queue.
so_5::disp::mpmc_queue_traits::lock_factory_t default_mpmc_queue_lock_factory() const
Get default lock_factory for MPMC queues.
so_5::msg_tracing::holder_t & msg_tracing_stuff() const
Get access to message delivery tracer stuff holder.
subscription_storage_factory_t default_subscription_storage_factory() const noexcept(noexcept(subscription_storage_factory_t{}=subscription_storage_factory_t{}))
Get the default storage subscription factory.
environment_t & m_env
Environment instance to work with.
void event_queue_on_unbind(agent_t *agent, event_queue_t *queue) noexcept
Call the event_queue_hook when an agent is being unbound from its event_queue.
mbox_t create_ordinary_mpsc_mbox(agent_t &single_consumer)
Create multi-producer/single-consumer mbox that handles message limits.
bool is_msg_tracing_enabled() const
Is message delivery tracing enabled?
so_5::msg_tracing::holder_t & msg_tracing_stuff_nonchecked() const noexcept
Get access to message delivery tracer stuff holder.
so_5::disp::mpsc_queue_traits::lock_factory_t default_mpsc_queue_lock_factory() const
Get default lock_factory for MPSC queues.
void final_deregister_coop(coop_shptr_t coop) noexcept
Do the final actions of a cooperation deregistration.
internal_env_iface_t(environment_t &env)
Initializing constructor.
mbox_t create_limitless_mpsc_mbox(agent_t &single_consumer)
Create multi-producer/single-consumer mbox that ignores message limits.
void ready_to_deregister_notify(coop_shptr_t coop) noexcept
Notification about readiness to the deregistration.
An utility class for working with layers.
Helper class for accessing protected members from mbox interface.
A base class for message sinks to be used by agents.
so_5::message_limit::control_block_t m_control_block
Run-time data for the message type.
void push_event(mbox_id_t mbox_id, message_delivery_mode_t delivery_mode, const std::type_index &msg_type, const message_ref_t &message, unsigned int redirection_deep, const message_limit::impl::action_msg_tracer_t *tracer) override
Get a message and push it to the appropriate destination.
void push_event(mbox_id_t mbox_id, message_delivery_mode_t, const std::type_index &msg_type, const message_ref_t &message, unsigned int, const message_limit::impl::action_msg_tracer_t *tracer) override
Get a message and push it to the appropriate destination.
Type that holds message_sink_with_message_limit objects.
message_sinks_with_limits_holder_t(partially_constructed_agent_ptr_t owner_ptr, so_5::message_limit::description_container_t &&descriptions)
Initializing constructor.
abstract_message_sink_t * find_or_create(const std::type_index &msg_type, partially_constructed_agent_ptr_t owner_ptr, const so_5::message_limit::description_t &limit_description)
static storage_t build_sinks(partially_constructed_agent_ptr_t owner_ptr, so_5::message_limit::description_container_t &&descriptions)
Helper for build an initial storage.
storage_t m_sinks
All created message_sinks.
abstract_message_sink_t * find(const std::type_index &msg_type)
An actual implementation of trace data interface.
void set_event_handler_data_ptr(const so_5::impl::event_handler_data_t *ptr) noexcept
void set_msg_type(const std::type_index &msg_type) noexcept
virtual optional< std::type_index > msg_type() const noexcept override
Get the information about message type.
void set_msg_source(so_5::msg_tracing::msg_source_t info) noexcept
virtual optional< const so_5::impl::event_handler_data_t * > event_handler_data_ptr() const noexcept override
Get pointer to event handler.
void set_compound_action(so_5::msg_tracing::compound_action_description_t desc) noexcept
optional< so_5::msg_tracing::message_instance_info_t > m_message_instance_info
optional< so_5::msg_tracing::compound_action_description_t > m_compound_action
void set_message_instance_info(so_5::msg_tracing::message_instance_info_t info) noexcept
virtual optional< so_5::msg_tracing::compound_action_description_t > compound_action() const noexcept override
Get the description of a compound action.
virtual optional< so_5::msg_tracing::message_instance_info_t > message_instance_info() const noexcept override
Get message instance information.
virtual optional< so_5::msg_tracing::msg_source_t > msg_source() const noexcept override
Get the information about message source.
optional< so_5::msg_tracing::message_or_signal_flag_t > m_message_or_signal
void set_message_or_signal(so_5::msg_tracing::message_or_signal_flag_t flag) noexcept
virtual optional< const agent_t * > agent() const noexcept override
Get a pointer to agent from trace message.
virtual optional< const abstract_message_sink_t * > message_sink() const noexcept override
Get a pointer to message_sink from trace message.
virtual optional< so_5::msg_tracing::message_or_signal_flag_t > message_or_signal() const noexcept override
Get message or signal information.
void set_message_sink(const abstract_message_sink_t *message_sink) noexcept
optional< const so_5::impl::event_handler_data_t * > m_event_handler_data_ptr
virtual optional< current_thread_id_t > tid() const noexcept override
Get the Thread ID from trace message.
deliver_op_tracer(const mchain_tracing_disabled_base &, const abstract_message_chain_t &, const std::type_index &, const message_ref_t &)
void make_trace(const char *action_name_suffix, Args &&... args) const
deliver_op_tracer(const mchain_tracing_enabled_base &tracing_base, const abstract_message_chain_t &chain, const std::type_index &msg_type, const message_ref_t &message)
Base class for a mchain for the case when message delivery tracing is enabled.
static const char * message_kind_to_string(const message_ref_t &what)
mchain_tracing_enabled_base(outliving_reference_t< so_5::msg_tracing::holder_t > tracer)
void trace_demand_drop_on_close(const abstract_message_chain_t &chain, const mchain_props::demand_t &d)
void trace_extracted_demand(const abstract_message_chain_t &chain, const mchain_props::demand_t &d)
const so_5::message_limit::impl::action_msg_tracer_t * overlimit_tracer() const
void message_rejected(const abstract_message_sink_t *, const delivery_possibility_t) const
deliver_op_tracer(const tracing_disabled_base &, const abstract_message_box_t &, const char *, message_delivery_mode_t, const std::type_index &, const message_ref_t &, const unsigned int)
void make_trace(const char *action_name_suffix, Args &&... args) const
void reaction_transform(const agent_t *subscriber, const mbox_t &target, const std::type_index &msg_type, const message_ref_t &transformed) const noexcept override
Message will be transformed and redirected.
void push_to_queue(const abstract_message_sink_t *sink, const agent_t *sink_owner) const noexcept override
Execution demand for agent will be pushed to the queue by a sink.
deliver_op_tracer(const tracing_enabled_base &tracing_base, const abstract_message_box_t &mbox, const char *op_name, message_delivery_mode_t delivery_mode, const std::type_index &msg_type, const message_ref_t &message, const unsigned int redirection_deep)
void reaction_redirect_message(const agent_t *subscriber, const mbox_t &target) const noexcept override
Message will be redirected to another mbox.
void reaction_abort_app(const agent_t *subscriber) const noexcept override
Application will be aborted as result of overlimit.
const so_5::message_limit::impl::action_msg_tracer_t * overlimit_tracer() const
void message_rejected(const abstract_message_sink_t *subscriber, const delivery_possibility_t status) const
void reaction_drop_message(const agent_t *subscriber) const noexcept override
Message will be dropped as result of overlimit.
Base class for a mbox for the case when message delivery tracing is enabled.
tracing_enabled_base(outliving_reference_t< so_5::msg_tracing::holder_t > tracer)
An interface for storage of message_sinks for one agent.
sinks_storage_t(const sinks_storage_t &)=delete
sinks_storage_t & operator=(const sinks_storage_t &)=delete
virtual abstract_message_sink_t * find_or_create(const std::type_index &msg_type)=0
virtual ~sinks_storage_t()=default
void add(internal_state_listener_unique_ptr_t listener)
Add a new listener.
static auto wrap_nondestroyable(agent_state_listener_t &listener)
static void actual_deleter(agent_state_listener_t *listener)
static void noop_deleter(agent_state_listener_t *)
void changed(agent_t &agent, const state_t &state) noexcept
Handle state change.
static auto wrap_destroyable(agent_state_listener_unique_ptr_t listener)
agent_t::agent_status_t m_previous_status
Definition agent.cpp:785
state_switch_guard_t(agent_t &agent)
Definition agent.cpp:788
abstract_message_sink_t * find_or_create(const std::type_index &) override
storage_without_limits_t(partially_constructed_agent_ptr_t owner_ptr)
message_sink_without_message_limit_t m_sink
The single sinks that is needed if message limits are not used.
An interface of subscription storage.
virtual void setup_content(subscription_storage_common::subscr_info_vector_t &&info)=0
Setup content from information from another storage object.
virtual void debug_dump(std::ostream &to) const =0
virtual const event_handler_data_t * find_handler(mbox_id_t mbox_id, const std::type_index &msg_type, const state_t &current_state) const noexcept=0
virtual std::size_t query_subscriptions_count() const =0
Count of subscriptions in the storage.
virtual void drop_subscription(const mbox_t &mbox, const std::type_index &msg_type, const state_t &target_state) noexcept=0
virtual subscription_storage_common::subscr_info_vector_t query_content() const =0
virtual void drop_subscription_for_all_states(const mbox_t &mbox, const std::type_index &msg_type) noexcept=0
virtual ~subscription_storage_t() noexcept=default
virtual void drop_content() noexcept=0
Drop all content.
virtual void create_event_subscription(const mbox_t &mbox, const std::type_index &msg_type, abstract_message_sink_t &message_sink, const state_t &target_state, const event_handler_method_t &method, thread_safety_t thread_safety, event_handler_kind_t handler_kind)=0
virtual void drop_all_subscriptions() noexcept=0
Drop all subscriptions.
Template class for smart reference wrapper on the atomic_refcounted_t.
bool operator==(const intrusive_ptr_t &o) const
intrusive_ptr_t(T *obj) noexcept
Constructor for a raw pointer.
T * m_obj
Object controlled by a smart reference.
void dismiss_object() noexcept
Decrement reference count to object and delete it if needed.
void reset() noexcept
Drop controlled object.
intrusive_ptr_t(const intrusive_ptr_t< Y > &o) noexcept
Constructor from another smart reference.
intrusive_ptr_t(std::unique_ptr< Y > o) noexcept
Constructor from unique_ptr instance.
intrusive_ptr_t(intrusive_ptr_t &&o) noexcept
Move constructor.
bool operator<(const intrusive_ptr_t &o) const
T * operator->() const noexcept
intrusive_ptr_t(const intrusive_ptr_t &o) noexcept
Copy constructor.
intrusive_ptr_t & operator=(const intrusive_ptr_t &o) noexcept
Copy operator.
intrusive_ptr_t & operator=(intrusive_ptr_t &&o) noexcept
Move operator.
intrusive_ptr_t< Y > make_reference() const noexcept
Make reference with casing to different type.
T & operator*() const noexcept
void take_object() noexcept
Increment reference count to object if it's not null.
friend void swap(intrusive_ptr_t &a, intrusive_ptr_t &b) noexcept
Swap values.
intrusive_ptr_t() noexcept
Default constructor.
T * get() const noexcept
~intrusive_ptr_t() noexcept
Destructor.
operator bool() const noexcept
Is this a null reference?
An interface of the additional SObjectizer Environment layer.
Definition so_layer.hpp:31
layer_t(layer_t &&)=delete
environment_t * m_env
SObjectizer Environment to which layer is bound.
Definition so_layer.hpp:85
layer_t(const layer_t &)=delete
layer_t()=default
layer_t & operator=(layer_t &&)=delete
virtual void start()
Start hook.
Definition so_layer.cpp:13
virtual void shutdown()
Shutdown signal hook.
Definition so_layer.cpp:18
virtual void wait()
Waiting for the complete shutdown of a layer.
Definition so_layer.cpp:23
layer_t & operator=(const layer_t &)=delete
environment_t & so_environment() const
Access to the SObjectizer Environment.
Definition so_layer.cpp:28
virtual ~layer_t() noexcept=default
void bind_to_environment(environment_t *env)
Bind layer to the SObjectizer Environment.
Definition so_layer.cpp:41
conductor_t(const Env &env, const char *file, unsigned int line)
conductor_t(error_logger_t &logger, const char *file, unsigned int line)
An implementation of delivery filter represented by lambda-function like object.
Definition mbox.hpp:126
bool check(const abstract_message_sink_t &, message_t &msg) const noexcept override
Checker for a message instance.
Definition mbox.hpp:135
A class for the name of mbox_namespace.
std::string_view m_name
The name.
mbox_namespace_name_t(std::string_view name)
Constructor with check for the empty value.
std::string_view query_name() const noexcept(noexcept(std::string_view{m_name}))
Get the value.
Basic parameters for advanced receive from mchain and for multi chain select.
Definition mchain.hpp:1215
actual_type & no_wait_on_empty() noexcept
Disable waiting on the empty queue.
Definition mchain.hpp:1332
actual_type & on_close(typename basic_t::chain_closed_handler_t handler) noexcept
Set handler for chain-closed event.
Definition mchain.hpp:1393
actual_type & stop_on(typename basic_t::stop_predicate_t predicate) noexcept
Set user condition for stopping receive operation.
Definition mchain.hpp:1359
mchain_bulk_processing_params_t(Data data)
Initializing constructor.
Definition mchain.hpp:1244
mchain_bulk_processing_params_t()=default
Default constructor.
decltype(auto) extract_n(std::size_t v) noexcept
Set limit for count of messages to be extracted.
Definition mchain.hpp:1276
actual_type & empty_timeout(Timeout v) noexcept
Set timeout for waiting on empty chain.
Definition mchain.hpp:1309
decltype(auto) handle_n(std::size_t v) noexcept
Set limit for count of messages to be handled.
Definition mchain.hpp:1293
decltype(auto) handle_all() noexcept
Definition mchain.hpp:1259
actual_type & total_time(Timeout v) noexcept
Set total time for the whole receive operation.
Definition mchain.hpp:1345
decltype(auto) clone_as_defined() noexcept
Definition mchain.hpp:1233
Parameters for message chain.
Definition mchain.hpp:729
mchain_props::not_empty_notification_func_t m_not_empty_notificator
An optional notificator for 'not_empty' condition.
Definition mchain.hpp:734
mchain_params_t(mchain_props::capacity_t capacity)
Initializing constructor.
Definition mchain.hpp:741
mchain_params_t & disable_msg_tracing()
Disable message delivery tracing explicitly.
Definition mchain.hpp:789
mchain_props::capacity_t m_capacity
Chain's capacity.
Definition mchain.hpp:731
mchain_params_t & capacity(mchain_props::capacity_t capacity)
Set chain's capacity and related params.
Definition mchain.hpp:749
bool msg_tracing_disabled() const
Is message delivery tracing disabled explicitly?
Definition mchain.hpp:797
const mchain_props::not_empty_notification_func_t & not_empty_notificator() const
Get chain's notificator for 'not_empty' condition.
Definition mchain.hpp:777
const mchain_props::capacity_t & capacity() const
Get chain's capacity and related params.
Definition mchain.hpp:757
bool m_msg_tracing_disabled
Is message delivery tracing disabled explicitly?
Definition mchain.hpp:737
mchain_params_t & not_empty_notificator(mchain_props::not_empty_notification_func_t notificator)
Set chain's notificator for 'not_empty' condition.
Definition mchain.hpp:768
Parameters for defining chain size.
Definition mchain.hpp:229
memory_usage_t memory_usage() const
Memory allocation type for size-limited chain.
Definition mchain.hpp:332
capacity_t(std::size_t max_size, memory_usage_t memory_usage, overflow_reaction_t overflow_reaction, duration_t overflow_timeout)
Initializing constructor for size-limited message chain.
Definition mchain.hpp:252
bool unlimited() const
Is message chain have no size limit?
Definition mchain.hpp:318
std::size_t m_max_size
Max size of the chain with limited size.
Definition mchain.hpp:236
overflow_reaction_t overflow_reaction() const
Overflow reaction for size-limited chain.
Definition mchain.hpp:339
overflow_reaction_t m_overflow_reaction
Type of reaction for chain overflow.
Definition mchain.hpp:242
capacity_t()
Default constructor.
Definition mchain.hpp:269
bool m_unlimited
Has chain unlimited size?
Definition mchain.hpp:231
static capacity_t make_unlimited()
Create capacity description for size-unlimited message chain.
Definition mchain.hpp:274
duration_t overflow_timeout() const
Get the value of waiting timeout for overflow case.
Definition mchain.hpp:356
static capacity_t make_limited_with_waiting(std::size_t max_size, memory_usage_t memory_usage, overflow_reaction_t overflow_reaction, duration_t wait_timeout)
Definition mchain.hpp:298
bool is_overflow_timeout_defined() const
Is waiting timeout for overflow case defined?
Definition mchain.hpp:346
static capacity_t make_limited_without_waiting(std::size_t max_size, memory_usage_t memory_usage, overflow_reaction_t overflow_reaction)
Definition mchain.hpp:279
memory_usage_t m_memory
Type of the storage for size-limited chain.
Definition mchain.hpp:239
duration_t m_overflow_timeout
Timeout for waiting on full chain during 'message push' operation.
Definition mchain.hpp:249
std::size_t max_size() const
Max size for size-limited chain.
Definition mchain.hpp:325
void set_on_close(chain_closed_handler_t handler) noexcept
Set handler for chain-closed event.
Definition mchain.hpp:1150
std::size_t to_handle() const noexcept
Get limit for count of message to be handled.
Definition mchain.hpp:1170
void set_extract_n(std::size_t v) noexcept
Set limit for count of messages to be extracted.
Definition mchain.hpp:1095
mchain_bulk_processing_basic_params_t(Basic_Data data)
Initializing constructor.
Definition mchain.hpp:1160
const mchain_props::duration_t & total_time() const noexcept
Get total time for the whole receive operation.
Definition mchain.hpp:1178
const stop_predicate_t & stop_on() const noexcept
Get user condition for stopping receive operation.
Definition mchain.hpp:1182
std::size_t to_extract() const noexcept
Get limit for count of messages to be extracted.
Definition mchain.hpp:1166
const chain_closed_handler_t & closed_handler() const noexcept
Get handler for chain-closed event.
Definition mchain.hpp:1189
void set_handle_n(std::size_t v) noexcept
Set limit for count of messages to be handled.
Definition mchain.hpp:1102
const mchain_props::duration_t & empty_timeout() const noexcept
Get timeout for waiting on empty chain.
Definition mchain.hpp:1174
void set_total_time(Timeout v) noexcept
Set total time for the whole receive operation.
Definition mchain.hpp:1129
const auto & so5_data() const noexcept
Access to internal data.
Definition mchain.hpp:1196
void set_stop_on(stop_predicate_t predicate) noexcept
Set user condition for stopping receive operation.
Definition mchain.hpp:1140
void set_empty_timeout(Timeout v) noexcept
Set timeout for waiting on empty chain.
Definition mchain.hpp:1117
Helper class with implementation of main actions of advanced receive operation.
Definition mchain.hpp:1560
receive_actions_performer_t(const mchain_receive_params_t< msg_count_status_t::defined > &params, const Bunch &bunch)
Definition mchain.hpp:1569
const mchain_receive_params_t< msg_count_status_t::defined > & m_params
Definition mchain.hpp:1561
Base class for representation of one case in multi chain select.
mchain_receive_params_t(typename base_type::data_type data)
Initializing constructor for the case of cloning.
Definition mchain.hpp:1479
const mchain_t & chain() const
Chain from which messages must be extracted and handled.
Definition mchain.hpp:1486
decltype(auto) so5_clone_if_necessary() noexcept
Definition mchain.hpp:1461
mchain_receive_params_t(mchain_t chain)
Initializing constructor.
Definition mchain.hpp:1472
A result of receive from mchain.
Definition mchain.hpp:922
std::size_t extracted() const noexcept
Count of extracted messages.
Definition mchain.hpp:954
std::size_t m_extracted
Count of extracted messages.
Definition mchain.hpp:924
mchain_props::extraction_status_t m_status
Extraction status (e.g. no messages, chain closed and so on).
Definition mchain.hpp:928
mchain_props::extraction_status_t status() const noexcept
Extraction status (e.g. no messages, chain closed and so on).
Definition mchain.hpp:964
std::size_t m_handled
Count of handled messages.
Definition mchain.hpp:926
std::size_t handled() const noexcept
Count of handled messages.
Definition mchain.hpp:959
mchain_receive_result_t(std::size_t extracted, std::size_t handled, mchain_props::extraction_status_t status) noexcept
Initializing constructor.
Definition mchain.hpp:939
mchain_receive_result_t() noexcept
Default constructor.
Definition mchain.hpp:932
A result of attempt of sending messages to a message chain.
Definition mchain.hpp:979
mchain_props::push_status_t status() const noexcept
Status of send operation.
Definition mchain.hpp:1012
mchain_props::push_status_t m_status
The status of send operation.
Definition mchain.hpp:984
mchain_send_result_t(std::size_t sent, mchain_props::push_status_t status)
Initializing constructor.
Definition mchain.hpp:997
mchain_send_result_t() noexcept
Default constructor.
Definition mchain.hpp:991
std::size_t m_sent
Count of messages sent.
Definition mchain.hpp:981
std::size_t sent() const noexcept
Count of messages sent.
Definition mchain.hpp:1007
A class for holding an instance of a message.
static message_holder_t make(Args &&...args)
Create a new instance of message_holder with a new message inside.
friend void swap(message_holder_t &a, message_holder_t &b) noexcept
message_holder_t(std::piecewise_construct_t, Args &&...args)
static intrusive_ptr_t< envelope_type > make_msg_instance(Args &&...args)
Create a new instance of message.
An interface of tracer for message delivery tracing.
virtual void reaction_redirect_message(const agent_t *subscriber, const mbox_t &target) const noexcept=0
Message will be redirected to another mbox.
virtual void push_to_queue(const abstract_message_sink_t *sink, const agent_t *sink_owner) const noexcept=0
Execution demand for agent will be pushed to the queue by a sink.
virtual void reaction_transform(const agent_t *subscriber, const mbox_t &target, const std::type_index &msg_type, const message_ref_t &transformed) const noexcept=0
Message will be transformed and redirected.
virtual void reaction_abort_app(const agent_t *subscriber) const noexcept=0
Application will be aborted as result of overlimit.
virtual void reaction_drop_message(const agent_t *subscriber) const noexcept=0
Message will be dropped as result of overlimit.
A base class for agent messages.
Definition message.hpp:47
message_t(const message_t &other)
Definition message.cpp:19
virtual void so5_change_mutability(message_mutability_t mutability)
Change message mutabilty flag.
Definition message.hpp:228
message_t & operator=(message_t &&other) noexcept
Definition message.cpp:39
friend message_mutability_t message_mutability(const message_t &what) noexcept
Helper method for get message mutability flag.
Definition message.hpp:86
virtual kind_t so5_message_kind() const noexcept
Detect the kind of the message.
Definition message.hpp:248
virtual ~message_t() noexcept=default
friend message_kind_t message_kind(const message_t &what)
Helper method for quering kind of the message.
Definition message.hpp:174
message_t & operator=(const message_t &other)
Definition message.cpp:32
message_mutability_t m_mutability
Is message mutable or immutable?
Definition message.hpp:188
friend message_mutability_t message_mutability(const intrusive_ptr_t< message_t > &what) noexcept
Helper method for safe get of message mutability flag.
Definition message.hpp:74
virtual message_mutability_t so5_message_mutability() const noexcept
Get message mutability flag.
Definition message.hpp:203
message_t(message_t &&other)
Definition message.cpp:25
friend void change_message_mutability(message_t &what, message_mutability_t mutability)
Helper method for change message mutability flag.
Definition message.hpp:130
friend message_kind_t message_kind(const so_5::intrusive_ptr_t< message_t > &what)
Helper method for quering kind of the message.
Definition message.hpp:154
friend void change_message_mutability(intrusive_ptr_t< message_t > &what, message_mutability_t mutability)
Helper method for safe change message mutability flag.
Definition message.hpp:107
A message wrapped to be used as type of argument for event handlers.
Definition mhood.hpp:570
mhood_t(message_ref_t &mf)
Definition mhood.hpp:574
An interface of filter for trace messages.
virtual ~filter_t() noexcept=default
virtual bool filter(const trace_data_t &data) noexcept=0
Filter the current message.
Interface of holder of message tracer and message trace filter objects.
holder_t & operator=(const holder_t &)=delete
virtual tracer_t & tracer() const noexcept=0
Get pointer to the message tracer object.
virtual bool is_msg_tracing_enabled() const noexcept=0
Is message tracing enabled?
virtual ~holder_t() noexcept=default
holder_t(const holder_t &)=delete
virtual filter_shptr_t take_filter() noexcept=0
Get access to the current message trace filter object.
A type of implementation of filters created from lambda function.
bool filter(const trace_data_t &data) noexcept override
Filter the current message.
An interface of object for accessing trace details.
virtual optional< std::type_index > msg_type() const noexcept=0
Get the information about message type.
virtual optional< message_or_signal_flag_t > message_or_signal() const noexcept=0
Get message or signal information.
virtual optional< msg_source_t > msg_source() const noexcept=0
Get the information about message source.
virtual ~trace_data_t() noexcept=default
virtual optional< message_instance_info_t > message_instance_info() const noexcept=0
Get message instance information.
virtual optional< compound_action_description_t > compound_action() const noexcept=0
Get the description of a compound action.
virtual optional< const so_5::agent_t * > agent() const noexcept=0
Get a pointer to agent from trace message.
trace_data_t(const trace_data_t &)=delete
virtual optional< current_thread_id_t > tid() const noexcept=0
Get the Thread ID from trace message.
trace_data_t & operator=(const trace_data_t &)=delete
virtual optional< const so_5::impl::event_handler_data_t * > event_handler_data_ptr() const noexcept=0
Get pointer to event handler.
virtual optional< const so_5::abstract_message_sink_t * > message_sink() const noexcept=0
Get a pointer to message_sink from trace message.
Interface of tracer object.
tracer_t & operator=(const tracer_t &)=delete
virtual void trace(const std::string &what) noexcept=0
tracer_t(const tracer_t &)=delete
tracer_t(tracer_t &&)=delete
virtual ~tracer_t() noexcept=default
tracer_t & operator=(tracer_t &&)=delete
Type for holding agent name.
unsigned int m_length
Name length.
name_for_agent_t & operator=(name_for_agent_t &&other) noexcept
Definition agent.cpp:142
name_for_agent_t(const name_for_agent_t &)
Definition agent.cpp:115
name_for_agent_t(name_for_agent_t &&other) noexcept
Definition agent.cpp:136
std::unique_ptr< char[] > m_value
Name storage.
bool has_value() const noexcept
Does this object have a value?
Definition agent.cpp:169
name_for_agent_t & operator=(const name_for_agent_t &)
Definition agent.cpp:129
std::string_view as_string_view() const
Get the value as a string_view.
Definition agent.cpp:160
name_for_agent_t()
Default constructor makes an null value.
Definition agent.cpp:104
operator bool() const noexcept
Does this object have a value?
name_for_agent_t(std::string_view value)
Initializing constructor.
Definition agent.cpp:108
A class for the name which cannot be empty.
nonempty_name_t(std::string name)
Constructor with check for the empty value.
const std::string & query_name() const noexcept
Get the value.
friend void swap(nonempty_name_t &a, nonempty_name_t &b) noexcept
nonempty_name_t(nonempty_name_t &&o) noexcept
std::string giveout_value() noexcept(noexcept(std::string{ std::move(m_nonempty_name) }))
Get the value away from the object.
nonempty_name_t(const char *name)
Constructor with check for the empty value.
nonempty_name_t & operator=(nonempty_name_t &&o) noexcept
nonempty_name_t(const nonempty_name_t &)=delete
nonempty_name_t & operator=(const nonempty_name_t &)=delete
std::string m_nonempty_name
Value.
Helper class for indication of long-lived reference via its type.
Definition outliving.hpp:98
outliving_reference_t(T &r) noexcept
outliving_reference_t & operator=(outliving_reference_t const &o)=delete
T & get() const noexcept
outliving_reference_t(outliving_reference_t< U > const &o) noexcept
outliving_reference_t(T &&)=delete
outliving_reference_t(outliving_reference_t const &o) noexcept
Wrapper around a pointer to partially constructed agent.
An implementation of backoff object using assembly instruction.
Definition spinlocks.hpp:60
Special container for holding receive parameters and receive cases.
Definition mchain.hpp:1871
prepared_receive_t(const prepared_receive_t &)=delete
prepared_receive_t(prepared_receive_t &&other)
Move constructor.
Definition mchain.hpp:1898
mchain_receive_params_t< mchain_props::msg_count_status_t::defined > m_params
Parameters for receive.
Definition mchain.hpp:1873
prepared_receive_t & operator=(const prepared_receive_t &)=delete
friend void swap(prepared_receive_t &a, prepared_receive_t &b) noexcept
Swap operation.
Definition mchain.hpp:1916
so_5::details::handlers_bunch_t< Handlers_Count > m_bunch
Cases for receive.
Definition mchain.hpp:1876
prepared_receive_t(mchain_receive_params_t< mchain_props::msg_count_status_t::defined > params, Handlers &&... cases)
Initializing constructor.
Definition mchain.hpp:1885
const auto & handlers() const noexcept
Definition mchain.hpp:1932
const auto & params() const noexcept
Definition mchain.hpp:1929
prepared_receive_t & operator=(prepared_receive_t &&other) noexcept
Move operator.
Definition mchain.hpp:1906
A base class for manager of default locks for event queues.
virtual ~queue_locks_defaults_manager_t() noexcept=default
virtual so_5::disp::mpsc_queue_traits::lock_factory_t mpsc_queue_lock_factory()=0
Get default lock_factory for MPSC queues.
queue_locks_defaults_manager_t & operator=(queue_locks_defaults_manager_t &&)=delete
virtual so_5::disp::mpmc_queue_traits::lock_factory_t mpmc_queue_lock_factory()=0
Get default lock_factory for MPMC queues.
queue_locks_defaults_manager_t & operator=(const queue_locks_defaults_manager_t &)=delete
queue_locks_defaults_manager_t(queue_locks_defaults_manager_t &&)=delete
queue_locks_defaults_manager_t(const queue_locks_defaults_manager_t &)=delete
Scoped guard for shared locks.
read_lock_guard_t(const read_lock_guard_t &)=delete
read_lock_guard_t & operator=(const read_lock_guard_t &)=delete
A simple multi-readers/single-writer spinlock (analog of std::shared_mutex).
void lock()
Lock object in exclusive mode.
static constexpr const std::uint_fast32_t unlocked
void unlock()
Unlock object locked in exclusive mode.
void unlock_shared()
Unlock object locked in shared mode.
std::atomic_uint_fast32_t m_counters
void lock_shared()
Lock object in shared mode.
static constexpr const std::uint_fast32_t write_lock
static constexpr const std::uint_fast32_t read_lock
rw_spinlock_t & operator=(const rw_spinlock_t &)=delete
rw_spinlock_t(const rw_spinlock_t &)=delete
A base class for agent signals.
Definition message.hpp:275
signal_t(const signal_t &)=delete
signal_t(signal_t &&)=delete
signal_t & operator=(signal_t &&)=delete
kind_t so5_message_kind() const noexcept override
Detect the kind of the message.
Definition message.hpp:293
signal_t & operator=(const signal_t &)=delete
~signal_t() noexcept override=default
signal_t()=default
abstract_message_sink_t & sink() noexcept override
Get a reference to the underlying message sink.
simple_sink_owner_t(Args &&...args)
Initializing constructor.
const abstract_message_sink_t & sink() const noexcept override
Get a const reference to the underlying message sink.
A simple spinlock (analog of std::mutex).
Definition spinlocks.hpp:93
void lock()
Lock object.
void unlock()
Unlock object.
spinlock_t(const spinlock_t &)=delete
std::atomic_bool m_flag
Atomic flag which is used as actual lock.
spinlock_t & operator=(spinlock_t &&)=delete
spinlock_t & operator=(const spinlock_t &)=delete
spinlock_t(spinlock_t &&)=delete
bool is_target(const agent_t *agent) const noexcept
Is agent owner of this state?
Definition agent.cpp:463
state_t & time_limit(duration_t timeout, const state_t &state_to_switch)
Set up a time limit for the state.
Definition agent.cpp:480
std::enable_if< details::is_agent_method_pointer< details::method_arity::nullary, Method_Pointer >::value, state_t & >::type on_enter(Method_Pointer pfn)
Set on enter handler.
Definition agent.hpp:3875
bool has_subscription(const mbox_t &from, Method_Pointer &&pfn) const
Check the presence of a subscription.
Definition agent.hpp:3782
const state_t & just_switch_to(mbox_t from, const state_t &target_state) const
Define handler which only switches agent to the specified state.
Definition agent.hpp:3833
state_t & drop_time_limit()
Drop time limit for the state if defined.
Definition agent.cpp:514
on_exit_handler_t m_on_exit
Handler for the exit from the state.
Definition state.hpp:1713
const state_t & suppress(mbox_t from) const
Suppress processing of event in this state.
Definition agent.hpp:3860
state_t & transfer_to_state(mbox_t from, const state_t &target_state)
An instruction for switching agent to the specified state and transfering event proceessing to new st...
Definition state.hpp:789
history_t m_state_history
Type of state history.
Definition state.hpp:1664
const state_t * parent_state() const noexcept
Get a parent state if exists.
Definition state.hpp:1748
void fill_path(path_t &path) const noexcept
A helper method for building a path from top-level state to this state.
Definition state.hpp:1793
state_t(substate_of parent, history_t state_history)
Constructor for the case when state is a substate of some parent state.
state_t & on_exit(on_exit_handler_t handler)
Set on exit handler.
Definition state.hpp:1338
state_t(initial_substate_of parent, std::string state_name, history_t state_history)
Constructor for the case when state is the initial substate of some parent state.
Definition agent.cpp:338
state_t(substate_of parent)
Constructor for the case when state is a substate of some parent state.
Definition agent.cpp:358
state_t & just_switch_to(mbox_t from, const state_t &target_state)
Define handler which only switches agent to the specified state.
Definition state.hpp:931
std::size_t nested_level() const noexcept
Query nested level for the state.
Definition state.hpp:1780
bool is_active() const noexcept
Is this state or any of its substates activated?
Definition agent.hpp:3751
state_t(state_t &&other)
Move constructor.
Definition agent.cpp:381
state_t(agent_t *target_agent, std::string state_name, state_t *parent_state, std::size_t nested_level, history_t state_history)
Fully initialized constructor.
Definition agent.cpp:273
const state_t & subscribe_message_handler(const mbox_t &from, Args &&... args) const
A helper for handle-methods implementation.
Definition agent.hpp:3915
const state_t & event(Args &&... args) const
Helper for subscription of event handler in this state.
Definition agent.hpp:3758
std::enable_if< details::is_agent_method_pointer< details::method_arity::nullary, Method_Pointer >::value, state_t & >::type on_exit(Method_Pointer pfn)
Set on exit handler.
Definition agent.hpp:3897
const state_t & suppress() const
Suppress processing of event in this state.
Definition agent.hpp:3853
std::string m_state_name
State name.
Definition state.hpp:1629
state_t(agent_t *agent, std::string state_name, history_t state_history)
Definition agent.cpp:320
bool has_subscription(const mbox_t &from) const
Check the presence of a subscription.
Definition agent.hpp:3775
state_t * m_parent_state
Parent state.
Definition state.hpp:1643
state_t(substate_of parent, std::string state_name, history_t state_history)
Constructor for the case when state is a substate of some parent state.
Definition agent.cpp:369
const state_t * actual_state_to_enter() const
Find actual state to be activated for agent.
Definition agent.cpp:526
void drop_subscription(const mbox_t &from, Method_Pointer &&pfn) const
Drop subscription.
Definition agent.hpp:3801
state_t & on_enter(on_enter_handler_t handler)
Set on enter handler.
Definition state.hpp:1209
state_t(initial_substate_of parent)
Constructor for the case when state is the initial substate of some parent state.
Definition agent.cpp:327
state_t & transfer_to_state(const state_t &target_state)
An instruction for switching agent to the specified state and transfering event proceessing to new st...
Definition state.hpp:830
const state_t * m_initial_substate
The initial substate.
Definition state.hpp:1656
bool operator==(const state_t &state) const noexcept
Definition agent.cpp:403
void clear_history() noexcept
Clear state history.
Definition state.hpp:449
state_t(initial_substate_of parent, std::string state_name)
Constructor for the case when state is the initial substate of some parent state.
Definition agent.cpp:332
state_t & event(mbox_t from, Args &&... args)
Definition state.hpp:531
const state_t & just_switch_to(const state_t &target_state) const
Define handler which only switches agent to the specified state.
Definition agent.hpp:3844
size_t m_substate_count
Number of substates.
Definition state.hpp:1697
state_t(agent_t *agent, history_t state_history)
Definition agent.cpp:307
const on_exit_handler_t & on_exit() const
Query on enter handler.
Definition state.hpp:1430
void call_on_enter() const noexcept
Call for on enter handler if defined.
Definition state.hpp:1837
bool operator!=(const state_t &state) const noexcept
Definition state.hpp:372
void call_on_exit() const noexcept
Call for on exit handler if defined.
Definition state.hpp:1850
agent_t *const m_target_agent
Owner of this state.
Definition state.hpp:1623
const state_t & transfer_to_state(mbox_t from, const state_t &target_state) const
An instruction for switching agent to the specified state and transfering event proceessing to new st...
Definition agent.hpp:3813
std::string query_name() const
Get textual name of the state.
Definition agent.cpp:409
state_t & operator=(const state_t &)=delete
const state_t & transfer_to_state(const state_t &target_state) const
An instruction for switching agent to the specified state and transfering event proceessing to new st...
Definition agent.hpp:3824
static constexpr const std::size_t max_deep
Max deep of nested states.
Definition state.hpp:163
state_t(substate_of parent, std::string state_name)
Constructor for the case when state is a substate of some parent state.
Definition agent.cpp:363
const state_t * m_last_active_substate
Last active substate.
Definition state.hpp:1676
void handle_time_limit_on_enter() const
A special handler of time limit to be used on entering into state.
Definition agent.cpp:570
state_t(agent_t *agent, std::string state_name)
Definition agent.cpp:314
state_t & suppress(mbox_t from)
Suppress processing of event in this state.
Definition state.hpp:1166
state_t(const state_t &)=delete
const state_t & event(mbox_t from, Args &&... args) const
Helper for subscription of event handler in this state.
Definition agent.hpp:3767
void activate() const
Switch agent to that state.
Definition agent.cpp:474
void drop_subscription(const mbox_t &from) const
Drop subscription.
Definition agent.hpp:3794
history_t
Type of history for state.
Definition state.hpp:172
@ none
State has no history.
@ deep
State has deep history.
@ shallow
State has shallow history.
on_enter_handler_t m_on_enter
Handler for the enter to the state.
Definition state.hpp:1705
const on_enter_handler_t & on_enter() const
Query on enter handler.
Definition state.hpp:1303
state_t & event(Args &&... args)
Definition state.hpp:488
std::unique_ptr< time_limit_t > m_time_limit
A definition of time limit for the state.
Definition state.hpp:1723
state_t & suppress()
Suppress processing of event in this state.
Definition state.hpp:1114
std::size_t m_nested_level
Nesting level for state.
Definition state.hpp:1686
void update_history_in_parent_states() const
A helper method which is used during state change for update state with history.
Definition agent.cpp:549
void handle_time_limit_on_exit() const
A special handler of time limit to be used on exiting from state.
Definition agent.cpp:576
state_t & just_switch_to(const state_t &target_state)
Define handler which only switches agent to the specified state.
Definition state.hpp:968
state_t(initial_substate_of parent, history_t state_history)
Constructor for the case when state is the initial substate of some parent state.
state_t(agent_t *agent)
Definition agent.cpp:301
A holder for data-souce that should be automatically registered and deregistered in registry.
outliving_reference_t< repository_t > m_repo
Repository for data source.
auto_registered_source_holder_t(outliving_reference_t< repository_t > repo, Args &&...args)
Initializing constructor.
Data_Source m_ds
Data source itself.
const Data_Source & get() const noexcept
auto_registered_source_holder_t(const auto_registered_source_holder_t &)=delete
auto_registered_source_holder_t(auto_registered_source_holder_t &&)=delete
A public interface for control SObjectizer monitoring options.
static std::chrono::steady_clock::duration default_distribution_period()
Default distribution period.
controller_t & operator=(const controller_t &)=delete
virtual void turn_on()=0
Turn the monitoring on.
controller_t(const controller_t &)=delete
virtual std::chrono::steady_clock::duration set_distribution_period(std::chrono::steady_clock::duration period)=0
Set distribution period.
controller_t & operator=(controller_t &&)=delete
controller_t(controller_t &&)=delete
virtual void turn_off()=0
Turn the monitoring off.
virtual const mbox_t & mbox() const =0
Get the mbox for receiving monitoring information.
An addition to auto_registered_source_holder for the cases where manual registration of data_source s...
manually_registered_source_holder_t(Args &&...args)
Initializing constructor.
void start(outliving_reference_t< repository_t > repo)
manually_registered_source_holder_t(const manually_registered_source_holder_t &)=delete
const Data_Source & get() const noexcept
repository_t * m_repo
Repository for data source.
manually_registered_source_holder_t(manually_registered_source_holder_t &&)=delete
An interface of data sources repository.
virtual void remove(source_t &what) noexcept=0
Deregistration of previously registered data source.
repository_t(repository_t &&)=delete
virtual void add(source_t &what)=0
Registration of new data source.
virtual ~repository_t() noexcept=default
static source_t * source_list_next(const source_t &what) noexcept
Helper method for accessing next data source in the list.
static void source_list_add(source_t &what, source_t *&head, source_t *&tail) noexcept
Helper method for adding data source to existing list.
static void source_list_remove(source_t &what, source_t *&head, source_t *&tail) noexcept
Helper method for removing data source from existing list.
repository_t(const repository_t &)=delete
repository_t & operator=(const repository_t &)=delete
repository_t & operator=(repository_t &&)=delete
An interface of data source.
virtual ~source_t() noexcept=default
source_t * m_prev
Previous item in the data sources list.
virtual void distribute(const mbox_t &)=0
Send appropriate notification about the current value.
source_t & operator=(source_t &&)=delete
source_t * m_next
Next item in the data sources list.
source_t & operator=(const source_t &)=delete
source_t(source_t &&)=delete
source_t(const source_t &)=delete
An interface of stop_guard entity.
setup_result_t
Type for result of setting up a new stop_guard.
@ ok
New stop_guard has be set successfully.
virtual void stop() noexcept=0
Perform stop-related actions.
stop_guard_t & operator=(stop_guard_t &&)=delete
stop_guard_t & operator=(const stop_guard_t &)=delete
@ throw_exception
An exception must be thrown.
@ return_negative_result
Return negative setup result.
stop_guard_t(const stop_guard_t &)=delete
stop_guard_t(stop_guard_t &&)=delete
stop_guard_t()=default
virtual ~stop_guard_t() noexcept=default
A class for creating a subscription to messages from the mbox.
Definition agent.hpp:174
std::enable_if< details::lambda_traits::is_lambda< Lambda >::value, subscription_bind_t & >::type event(Lambda &&lambda, thread_safety_t thread_safety=not_thread_safe)
Make subscription to the message by lambda-function.
Definition agent.hpp:3510
std::enable_if< details::is_agent_method_pointer< details::method_arity::unary, Method_Pointer >::value, subscription_bind_t & >::type event(Method_Pointer pfn, thread_safety_t thread_safety=not_thread_safe)
Make subscription to the message.
Definition agent.hpp:3490
std::vector< const state_t * > state_vector_t
Type of vector of states.
Definition agent.hpp:414
mbox_t m_mbox_ref
Mbox for messages to subscribe.
Definition agent.hpp:407
subscription_bind_t & just_switch_to(const state_t &target_state)
Define handler which only switches agent to the specified state.
Definition agent.hpp:3689
void create_subscription_for_states(const std::type_index &msg_type, const event_handler_method_t &method, thread_safety_t thread_safety, event_handler_kind_t handler_kind) const
Create subscription of event for all states.
Definition agent.hpp:3712
subscription_bind_t(agent_t &agent, const mbox_t &mbox_ref)
Definition agent.hpp:3460
subscription_bind_t & in(const state_t &state)
Set up a state in which events are allowed be processed.
Definition agent.hpp:3469
subscription_bind_t & suppress()
Suppress processing of event in this state.
Definition agent.hpp:3665
subscription_bind_t & transfer_to_state(const state_t &target_state)
An instruction for switching agent to the specified state and transfering event proceessing to new st...
Definition agent.hpp:3532
state_vector_t m_states
States of agents the event to be subscribed in.
Definition agent.hpp:421
void ensure_handler_can_be_used_with_mbox(const so_5::details::msg_type_and_handler_pair_t &handler) const
Additional check for subscription to a mutable message from MPMC mbox.
Definition agent.hpp:3739
agent_t * m_agent
Agent to which we are subscribing.
Definition agent.hpp:405
An indentificator for the timer.
Definition timers.hpp:73
timer_id_t() noexcept=default
Default constructor.
void release() noexcept
Release the timer event.
Definition timers.hpp:99
timer_id_t(so_5::intrusive_ptr_t< timer_t > &&timer) noexcept
Initializing constructor.
Definition timers.hpp:78
friend void swap(timer_id_t &a, timer_id_t &b) noexcept
Swapping.
Definition timers.hpp:85
bool is_active() const noexcept
Is this timer event is active?
Definition timers.hpp:92
so_5::intrusive_ptr_t< timer_t > m_timer
Actual timer.
Definition timers.hpp:107
An interface for collector of elapsed timers.
Definition timers.hpp:436
elapsed_timers_collector_t & operator=(const elapsed_timers_collector_t &)=delete
elapsed_timers_collector_t(const elapsed_timers_collector_t &)=delete
virtual void accept(std::type_index type_index, mbox_t mbox, message_ref_t msg)=0
Accept and store info about elapsed timer.
virtual ~elapsed_timers_collector_t() noexcept=default
Timer manager interface.
Definition timers.hpp:409
virtual void schedule_anonymous(const std::type_index &type_index, const mbox_t &mbox, const message_ref_t &msg, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period)=0
Push anonymous delayed/periodic message to the timer queue.
virtual bool empty()=0
virtual std::chrono::steady_clock::duration timeout_before_nearest_timer(std::chrono::steady_clock::duration default_timer)=0
Calculate time before the nearest timer (if any).
virtual void process_expired_timers()=0
Translation of expired timers into message sends.
virtual ~timer_manager_t() noexcept=default
virtual timer_id_t schedule(const std::type_index &type_index, const mbox_t &mbox, const message_ref_t &msg, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period)=0
Push delayed/periodic message to the timer queue.
timer_manager_t() noexcept=default
virtual timer_thread_stats_t query_stats()=0
Get statistics for run-time monitoring.
timer_manager_t(const timer_manager_t &)=delete
timer_manager_t & operator=(const timer_manager_t &)=delete
A base class for timer identificator.
Definition timers.hpp:48
virtual ~timer_t() noexcept=default
virtual void release() noexcept=0
Release the timer event.
virtual bool is_active() const noexcept=0
Is this timer event is active?
Timer thread interface.
Definition timers.hpp:146
virtual void finish()=0
Finish timer and wait for full stop.
virtual void schedule_anonymous(const std::type_index &type_index, const mbox_t &mbox, const message_ref_t &msg, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period)=0
Push anonymous delayed/periodic message to the timer queue.
virtual timer_thread_stats_t query_stats()=0
Get statistics for run-time monitoring.
timer_thread_t & operator=(const timer_thread_t &)=delete
timer_thread_t()=default
virtual void start()=0
Launch timer.
timer_thread_t(const timer_thread_t &)=delete
virtual ~timer_thread_t()=default
virtual timer_id_t schedule(const std::type_index &type_index, const mbox_t &mbox, const message_ref_t &msg, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period)=0
Push delayed/periodic message to the timer queue.
A result of message transformation.
transformed_message_t(mbox_t mbox, std::unique_ptr< typename message_payload_type< Msg >::envelope_type > msg)
Initializing constructor for the case when Msg is a message type.
message_ref_t m_message
Instance of transformed message.
const mbox_t & mbox() const
Destination message box.
mbox_t m_mbox
Destination message box.
std::type_index msg_type() const
Type of the transformed message.
transformed_message_t(mbox_t mbox)
Initializing constructor for the case when Msg is a signal type.
const message_ref_t & message() const
Instance of transformed message.
static transformed_message_t< Msg > make(mbox_t mbox, Args &&... args)
A helper method for transformed_message construction.
transformed_message_t(mbox_t mbox, message_holder_t< Msg_In_Holder, Ownership > msg_holder)
An implementation of backoff object with usage of std::yield.
Definition spinlocks.hpp:38
#define SO_5_EXPORT
Definition declspec.hpp:26
#define SO_5_TYPE
Definition declspec.hpp:46
#define SO_5_IMPORT
Definition declspec.hpp:27
#define SO_5_FUNC
Definition declspec.hpp:48
#define SO_5_LOG_ERROR(logger, var_name)
A special macro for helping error logging.
#define SO_5_LOG_ERROR_IMPL(logger, file, line, var_name)
An implementation for SO_5_LOG_ERROR macro.
#define SO_5_THROW_EXCEPTION_IMPL(file, line, error_code, desc)
Definition exception.hpp:71
#define SO_5_THROW_EXCEPTION(error_code, desc)
Definition exception.hpp:74
demand_handler_pfn_t select_demand_handler_for_message(const agent_t &agent, const message_ref_t &msg)
A helper function to select actual demand handler in dependency of message kind.
Definition agent.cpp:1227
mbox_t make_direct_mbox_with_respect_to_custom_factory(partially_constructed_agent_ptr_t agent_ptr, const agent_tuning_options_t &tuning_options, mbox_t standard_mbox)
Helper for creation of the direct mbox for an agent.
Definition agent.cpp:593
unsigned int ensure_valid_agent_name_length(std::size_t length)
Definition agent.cpp:83
std::string create_anonymous_state_name(const agent_t *agent, const state_t *st)
Definition agent.cpp:183
const state_t deadletter_state(nullptr, "<DEADLETTER_STATE>")
A special object to be used as state for make subscriptions for deadletter handlers.
subscription_storage_factory_t detect_subscription_storage_factory_to_use(environment_t &env, const agent_tuning_options_t &tuning_options)
Helper for selection of subscription storage factory.
Definition agent.cpp:630
const state_t awaiting_deregistration_state(nullptr, "<AWAITING_DEREGISTRATION_AFTER_UNHANDLED_EXCEPTION>")
A special object for the state in which agent is awaiting for deregistration after unhandled exceptio...
Enumeration of cooperation deregistration reasons.
Definition coop.hpp:39
const int unknown_error
Deregistration because of unknown error.
Definition coop.hpp:58
const int user_defined_reason
A starting point for user-defined reasons.
Definition coop.hpp:64
const int parent_deregistration
Deregistration because parent cooperation deregistration.
Definition coop.hpp:52
const int undefined
Reason is not properly defined.
Definition coop.hpp:61
const int unhandled_exception
Deregistration because of unhandled exception.
Definition coop.hpp:55
const int normal
Normal deregistration.
Definition coop.hpp:46
const int shutdown
Deregistration because SObjectizer Environment shutdown.
Definition coop.hpp:49
Various helpers for event subscription.
Agent * get_actual_agent_pointer(agent_t &agent)
Get actual agent pointer.
std::enable_if< is_agent_method_pointer< method_arity::unary, Method_Pointer >::value, msg_type_and_handler_pair_t >::type make_handler_with_arg_for_agent(Agent *agent, Method_Pointer pfn)
Helper template for creation of event handler with actual argument.
details::msg_type_and_handler_pair_t make_handler_from_lambda_of_free_function(Lambda &&lambda)
A function for creation event handler.
msg_type_and_handler_pair_t make_handler_with_arg(Handler_Type lambda)
Helper template for creation of event handler with actual argument.
void ensure_handler_can_be_used_with_mbox(const ::so_5::details::msg_type_and_handler_pair_t &handler, const ::so_5::mbox_t &target_mbox)
Ensure that mutability of message is compatible with mutability of target mbox.
Helpers for manipulation with standard C++ I/O streams.
Internal implementation details.
Helper templates for detection of lambda-type traits.
M * get_ptr(const intrusive_ptr_t< user_type_message_t< M > > &msg) noexcept
A helper function to get a const raw pointer from smart pointer.
M * get_ptr(const intrusive_ptr_t< M > &msg) noexcept
A helper function to get a const raw pointer from smart pointer.
Implementation details for implementation of rollback on exception helper.
Some reusable and low-level classes/functions which can be used in public header files.
auto make_message_instance(Args &&... args) -> std::unique_ptr< typename message_payload_type< Msg >::envelope_type >
A helper for allocate instance of a message.
Definition message.hpp:841
mhood_type_t
A special selector for mhood_t implementations.
Definition mhood.hpp:35
@ classical_signal
Message type is a classical signal derived from so_5::signal_t.
@ classical_message
Message type is a classical message derived from so_5::message_t.
@ user_type_message
Message type is not related to so_5::message_t.
void abort_on_fatal_error(L logging_lambda) noexcept
void fill_handlers_bunch(Bunch &bunch, std::size_t index, Lambda &&lambda, Others &&... other_handlers)
auto do_with_rollback_on_exception(Main_Action main_action, Rollback_Action rollback_action) -> decltype(main_action())
Helper function for do some action with rollback in the case of an exception.
void fill_handlers_bunch(Bunch &bunch, std::size_t index, msg_type_and_handler_pair_t &&handler, Others &&... other_handlers)
void fill_handlers_bunch(Bunch &bunch, std::size_t)
auto invoke_noexcept_code(L lambda) noexcept -> decltype(lambda())
method_arity
A special enumeration to specify arity of lambda-function or method.
@ nullary
Method or function has no arguments.
@ unary
Method or function has just one argument.
scope_exit_details::at_exit_t< L > at_scope_exit(L &&l)
Helper function for creation action to be performed at scope exit.
Various stuff related to MPMC event queue implementation and tuning.
std::chrono::high_resolution_clock::duration default_combined_lock_waiting_time()
Default timeout used by combined_lock for waiting on spinlock before switching to mutex-based locking...
SO_5_FUNC lock_factory_t combined_lock_factory(std::chrono::high_resolution_clock::duration waiting_time)
Factory for creation of combined queue lock with the specified waiting time.
lock_factory_t combined_lock_factory()
Factory for creation of combined queue lock with default waiting time.
SO_5_FUNC lock_factory_t simple_lock_factory()
Factory for creation of very simple implementation based on usage of mutex and condition_variable onl...
Various stuff related to MPSC event queue implementation and tuning.
lock_factory_t combined_lock_factory()
Factory for creation of combined queue lock with default waiting time.
SO_5_FUNC lock_factory_t simple_lock_factory()
Factory for creation of very simple implementation based on usage of mutex and condition_variable onl...
SO_5_FUNC lock_factory_t combined_lock_factory(std::chrono::high_resolution_clock::duration waiting_time)
Factory for creation of combined queue lock with the specified waiting time.
std::chrono::high_resolution_clock::duration default_combined_lock_waiting_time()
Default timeout used by combined_lock for waiting on spinlock before switching to mutex-based locking...
Dispatcher with single working thread.
Reusable components for dispatchers.
Event dispatchers.
SO_5_FUNC abstract_work_thread_factory_shptr_t make_std_work_thread_factory()
Get a standard SObjectizer's work thread factory that is used by default.
envelope_t & message_to_envelope(const message_ref_t &src_msg)
A helper function for casting message instance to envelope instance.
SO_5_FUNC optional< message_ref_t > message_to_be_inspected(const message_ref_t &msg_or_envelope)
Helper function for extraction of a payload from enveloped message.
SO_5_FUNC optional< payload_info_t > extract_payload_for_message_transformation(const message_ref_t &envelope)
Helper function for extraction of a payload from enveloped message.
access_context_t
Information about context on that enveloped message is handled.
Internal namespace with details of agent_t implementation.
Definition agent.hpp:462
std::tuple< so_5::message_limit::description_container_t, std::optional< so_5::message_limit::description_t > > prepare(so_5::message_limit::description_container_t original_descriptions)
void append_dummy_limit_for_state_timeout_msg(so_5::message_limit::description_container_t &original_descriptions)
Check presence of limit for msg_state_timeout and add it of there is no such a limit.
Low-level details of message delivery tracing implementation.
void make_trace_to_1(std::ostream &s, const agent_t *agent)
void fill_trace_data_1(actual_trace_data_t &d, current_thread_id_t tid)
void make_trace_to_1(std::ostream &s, const redirection_deep limit)
void fill_trace_data_1(actual_trace_data_t &d, mbox_identification id)
void fill_trace_data_1(actual_trace_data_t &d, const original_msg_type msg_type)
void make_trace_to_1(std::ostream &s, current_thread_id_t tid)
void make_trace_to_1(std::ostream &s, const type_of_removed_msg msg_type)
void make_trace(so_5::msg_tracing::holder_t &msg_tracing_stuff, Args &&... args) noexcept
void make_trace_to_1(std::ostream &s, const so_5::message_limit::control_block_t *limit)
void make_trace_to_1(std::ostream &s, const abstract_message_sink_t *sink)
void make_trace_to_1(std::ostream &s, const composed_action_name name)
void fill_trace_data_1(actual_trace_data_t &d, const event_handler_data_t *handler)
void fill_trace_data_1(actual_trace_data_t &, message_delivery_mode_t)
void make_trace_to_1(std::ostream &s, const mbox_as_msg_destination mbox)
void fill_trace_data_1(actual_trace_data_t &, const so_5::message_limit::control_block_t *)
void make_trace_to_1(std::ostream &s, mbox_identification id)
void fill_trace_data_1(actual_trace_data_t &d, const agent_t *agent)
void make_trace_to_1(std::ostream &s, message_delivery_mode_t mode)
void fill_trace_data_1(actual_trace_data_t &, const mbox_as_msg_destination &)
void make_trace_to_1(std::ostream &s, mchain_identification id)
void fill_trace_data_1(actual_trace_data_t &d, const abstract_message_chain_t &chain)
void make_trace_to_1(std::ostream &s, const original_msg_type msg_type)
void fill_trace_data_1(actual_trace_data_t &d, const mbox_as_msg_source &mbox)
void fill_trace_data_1(actual_trace_data_t &, chain_size)
void fill_trace_data_1(actual_trace_data_t &, const type_of_transformed_msg)
void fill_trace_data_1(actual_trace_data_t &d, const composed_action_name name)
void fill_trace_data_1(actual_trace_data_t &d, const message_ref_t &message)
void fill_trace_data(actual_trace_data_t &d, A &&a, Other &&... other)
void make_trace_to_1(std::ostream &s, const abstract_message_chain_t &chain)
void fill_trace_data_1(actual_trace_data_t &, const text_separator)
void fill_trace_data_1(actual_trace_data_t &d, mchain_identification id)
void make_trace_to_1(std::ostream &s, const type_of_transformed_msg msg_type)
void make_trace_to_1(std::ostream &s, const mbox_as_msg_source mbox)
void make_trace_to_1(std::ostream &s, const state_t *state)
void make_trace_to(std::ostream &s, A &&a, Other &&... other)
void make_trace_to_1(std::ostream &s, const event_handler_data_t *handler)
void make_trace_to_1(std::ostream &s, chain_size size)
void make_trace_to_1(std::ostream &s, const text_separator text)
void fill_trace_data_1(actual_trace_data_t &d, const abstract_message_sink_t *sink)
void fill_trace_data_1(actual_trace_data_t &, const type_of_removed_msg)
void fill_trace_data_1(actual_trace_data_t &, const state_t *)
void make_trace_to_1(std::ostream &s, const message_ref_t &message)
void fill_trace_data_1(actual_trace_data_t &, const redirection_deep)
Various helpers for message delivery tracing mechanism.
void safe_trace_state_leaving(const agent_t &state_owner, const state_t &state)
Helper for tracing the fact of leaving a state.
void safe_trace_state_entering(const agent_t &state_owner, const state_t &state)
Helper for tracing the fact of entering into a state.
void trace_deadletter_handler_search_result(const execution_demand_t &demand, const char *context_marker, const event_handler_data_t *search_result)
Helper for tracing the result of search of deadletter handler.
void trace_event_handler_search_result(const execution_demand_t &demand, const char *context_marker, const event_handler_data_t *search_result)
Helper for tracing the result of event handler search.
Common stuff for various subscription storage implementations.
std::string make_subscription_description(const mbox_t &mbox_ref, std::type_index msg_type, const state_t &state)
A helper function for creating subscription description.
Details of SObjectizer run-time implementations.
Definition agent.cpp:780
so_5::disp::mpsc_queue_traits::lock_factory_t default_lock_factory(environment_t &env, const so_5::disp::mpsc_queue_traits::lock_factory_t &)
Helper function to be used for extraction of lock_factory for MPSC queues.
void process_unhandled_unknown_exception(current_thread_id_t working_thread_id, agent_t &a_exception_producer) noexcept
Processor of unhandled exception of unknown type from agent's event handler.
so_5::disp::mpmc_queue_traits::lock_factory_t default_lock_factory(environment_t &env, const so_5::disp::mpmc_queue_traits::lock_factory_t &)
Helper function to be used for extraction of lock_factory for MPSC queues.
void process_unhandled_exception(current_thread_id_t working_thread_id, const std::exception &ex, agent_t &a_exception_producer) noexcept
Processor of unhandled exception from agent's event handler.
static std::unique_ptr< sinks_storage_t > create_sinks_storage_if_necessary(partially_constructed_agent_ptr_t owner_ptr, so_5::message_limit::description_container_t &&descriptions)
Create info_storage object if there are some message limits.
void wrap_init_fn_call(Init_Fn init_fn)
A special wrapper for calling init function.
timer_thread_unique_ptr_t create_appropriate_timer_thread(error_logger_shptr_t error_logger, const timer_thread_factory_t &user_factory)
Helper function for timer_thread creation.
Definition timers.hpp:754
Implementation details of error_logging facility.
so_5::timer_id_t schedule_timer(const std::type_index &subscription_type, message_ref_t msg, const mbox_t &mbox, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period)
Schedule periodic timer event.
void ensure_not_null(const delivery_filter_unique_ptr_t &ptr)
Helper function that throws if a pointer to delivery_filter is null.
Definition mbox.hpp:107
void single_timer(const std::type_index &subscription_type, message_ref_t msg, const mbox_t &mbox, std::chrono::steady_clock::duration pause)
Schedule single timer event.
void deliver_message(message_delivery_mode_t delivery_mode, abstract_message_box_t &target, std::type_index subscription_type, message_ref_t msg)
Deliver message.
Definition mbox.hpp:413
coop_shptr_t to_shptr_noexcept(const coop_handle_t &) noexcept
A helper function for unsafe extraction of shared_ptr to coop from coop_handle instance.
void deliver_signal(message_delivery_mode_t delivery_mode, abstract_message_box_t &target)
Deliver signal.
Definition mbox.hpp:445
void deliver_message(message_delivery_mode_t delivery_mode, abstract_message_box_t &target, std::type_index subscription_type, std::unique_ptr< Message > msg)
Deliver message.
Definition mbox.hpp:379
coop_shptr_t to_shptr(const coop_handle_t &)
A helper function for safe extraction of shared_ptr to coop from coop_handle instance.
Implementation details.
Definition mchain.hpp:37
bool is_infinite_wait_timevalue(duration_t v)
Is time value means 'infinite_wait'?
Definition mchain.hpp:84
bool is_no_wait_timevalue(duration_t v)
Is time value means 'no_wait'?
Definition mchain.hpp:70
mchain_receive_result_t receive_without_total_time(const mchain_receive_params_t< msg_count_status_t::defined > &params, const Bunch &bunch)
An implementation of advanced receive when there is no limit for total operation time is defined.
Definition mchain.hpp:1691
duration_t actual_timeout(no_wait_indication)
Helper function for detection of actual value for waiting timeout.
Definition mchain.hpp:116
duration_t actual_timeout(V value)
Helper function for detection of actual value for waiting timeout.
Definition mchain.hpp:128
mchain_receive_result_t receive_with_finite_total_time(const mchain_receive_params_t< msg_count_status_t::defined > &params, const Bunch &bunch)
An implementation of advanced receive when a limit for total operation time is defined.
Definition mchain.hpp:1647
duration_t infinite_wait_special_timevalue()
Special value of duration to indicate 'infinite_wait' case.
Definition mchain.hpp:59
mchain_receive_result_t perform_receive(const mchain_receive_params_t< msg_count_status_t::defined > &params, const Bunch &bunch)
An implementation of main receive actions.
Definition mchain.hpp:1721
duration_t no_wait_special_timevalue()
Special value of duration to indicate 'no_wait' case.
Definition mchain.hpp:48
duration_t actual_timeout(infinite_wait_indication)
Helper function for detection of actual value for waiting timeout.
Definition mchain.hpp:102
Various properties and parameters of message chains.
Definition mchain.hpp:28
close_mode_t
What to do with chain's content at close.
Definition mchain.hpp:410
@ drop_content
All messages must be removed from chain.
overflow_reaction_t
What reaction must be performed on attempt to push new message to the full message chain.
Definition mchain.hpp:199
@ remove_oldest
Oldest message in chain must be removed.
@ drop_newest
New message must be ignored and droped.
@ abort_app
Application must be aborted.
@ throw_exception
An exception must be thrown.
msg_count_status_t
Status of limit for messages to be extracted/handled during a bulk operation on a mchain.
Definition mchain.hpp:1027
@ undefined
Message count limit is not set yet.
@ defined
Message count limit is set.
extraction_status_t
Result of extraction of message from a message chain.
Definition mchain.hpp:371
@ msg_extracted
Message extracted successfully.
@ chain_closed
Message cannot be extracted because chain is closed.
@ no_messages
No available messages in the chain.
push_status_t
Result of attempt of pushing a message into a message chain.
Definition mchain.hpp:389
@ not_stored
Message wasn't stored.
@ stored
Message stored into a message chain.
@ chain_closed
Message wasn't stored because chain is closed.
memory_usage_t
Memory allocation for storage for size-limited chains.
Definition mchain.hpp:182
@ preallocated
Storage must be preallocated once and doesn't change after that.
@ dynamic
Storage can be allocated and deallocated dynamically.
Internal implementation of message limits related stuff.
Definition message.hpp:883
action_t make_action_for_message_transformer(Lambda &&transformator)
Helper function to make an action that performs message transformation.
SO_5_FUNC void redirect_reaction(const overlimit_context_t &ctx, const mbox_t &to)
Actual implementation of redirect message reaction.
SO_5_FUNC void abort_app_reaction(const overlimit_context_t &ctx)
Actual implementation of abort application reaction.
SO_5_FUNC void drop_message_reaction(const overlimit_context_t &ctx)
Actual implementation of drop message reaction.
action_t make_action_for_signal_transformer(Lambda &&transformator)
Helper function to make an action that performs signal transformation.
SO_5_FUNC void transform_reaction(const overlimit_context_t &ctx, const mbox_t &to, const std::type_index &msg_type, const message_ref_t &message)
Actual implementation of transform reaction.
All stuff related to message limits.
Definition message.hpp:862
void accept_one_indicator(description_container_t &to, const log_then_abort_app_indicator_t< M, L > &indicator)
Helper function for accepting log_then_abort_app_indicator and storing the corresponding description ...
void accept_indicators(description_container_t &)
void accept_indicators(description_container_t &to, I &&indicator, Args &&... others)
Helper function for constructing limits description from a series of limit indicators.
void accept_one_indicator(description_container_t &to, const drop_indicator_t< M > &indicator)
Helper function for accepting drop_indicator and storing the corresponding description into the limit...
void accept_one_indicator(description_container_t &to, transform_indicator_t< M > indicator)
Helper function for accepting transform_indicator and storing the corresponding description into the ...
void accept_one_indicator(description_container_t &to, const abort_app_indicator_t< M > &indicator)
Helper function for accepting abort_app_indicator and storing the corresponding description into the ...
void accept_one_indicator(description_container_t &to, redirect_indicator_t< Msg, Lambda > indicator)
Helper function for accepting redirect_indicator and storing the corresponding description into the l...
Implementation details of message delivery tracing mechanism.
Public part of message delivery tracing mechanism.
SO_5_FUNC tracer_unique_ptr_t std_cerr_tracer()
Factory for tracer which uses std::cerr stream.
SO_5_FUNC tracer_unique_ptr_t std_clog_tracer()
Factory for tracer which uses std::clog stream.
filter_shptr_t make_enable_all_filter()
A helper function for creation of filter that enables all messages.
SO_5_FUNC tracer_unique_ptr_t std_cout_tracer()
Factory for tracer which uses std::cout stream.
message_or_signal_flag_t
A flag for message/signal dichotomy.
filter_shptr_t no_filter()
A helper function to be used when it is necessary to remove msg_tracing's filter.
msg_source_type_t
Type of message source.
@ mchain
The source is a mchain.
filter_shptr_t make_filter(L &&lambda)
A helper function for creation of new filter from lambda-function.
filter_shptr_t make_disable_all_filter()
A helper function for creation of filter that disables all messages.
status_t
Status of message delivery tracing.
@ disabled
Message delivery tracing is disabled.
@ enabled
Message delivery tracing is enabled.
Helpers for working with priorities.
Definition priority.hpp:73
const priority_t p0
Definition priority.hpp:79
const priority_t p5
Definition priority.hpp:84
void for_each_priority(Lambda l)
Does enumeration of all priorities.
Definition priority.hpp:193
const priority_t p7
Definition priority.hpp:86
const priority_t p3
Definition priority.hpp:82
const priority_t p6
Definition priority.hpp:85
const priority_t p1
Definition priority.hpp:80
const priority_t p2
Definition priority.hpp:81
priority_t prev(priority_t p)
Get the previous priority value.
Definition priority.hpp:155
bool has_prev(priority_t p)
Is there lower priority?
Definition priority.hpp:143
const priority_t default_priority
Default priority value.
Definition priority.hpp:97
priority_t next(priority_t p)
Get the next priority value.
Definition priority.hpp:128
const priority_t p4
Definition priority.hpp:83
bool has_next(priority_t p)
Is there higher priority?
Definition priority.hpp:116
const unsigned int total_priorities_count
Total count of priorities.
Definition priority.hpp:105
Implementation details for send-family and request_future/value helper functions.
so_5::environment_t & arg_to_env(const so_5::mchain_t &chain)
const so_5::mbox_t & arg_to_mbox(const so_5::agent_t &agent)
const so_5::mbox_t & arg_to_mbox(const so_5::mbox_t &mbox)
so_5::environment_t & arg_to_env(const so_5::mbox_t &mbox)
so_5::environment_t & arg_to_env(const so_5::agent_t &agent)
so_5::mbox_t arg_to_mbox(const so_5::mchain_t &chain)
All stuff related to run-time monitoring and statistics.
Private part of message limit implementation.
Definition agent.cpp:33
std::size_t to_size_t(priority_t priority)
Helper function for conversion from priority to size_t.
Definition priority.hpp:48
const int rc_nullptr_as_result_of_user_mbox_factory
nullptr returned by user-provided mbox factory.
Definition ret_code.hpp:468
event_queue_hook_unique_ptr_t make_event_queue_hook(event_queue_hook_deleter_fnptr_t deleter, Args &&...args)
Helper function for simplify creation of event_queue_hook object.
SO_5_FUNC queue_locks_defaults_manager_unique_ptr_t make_defaults_manager_for_combined_locks()
A factory for queue_locks_defaults_manager with generators for combined locks.
SO_5_FUNC timer_manager_unique_ptr_t create_timer_heap_manager(error_logger_shptr_t logger, outliving_reference_t< timer_manager_t::elapsed_timers_collector_t > collector, std::size_t initial_heap_capacity)
Create timer manager based on timer_heap mechanism.
Definition timers.cpp:619
SO_5_FUNC subscription_storage_factory_t flat_set_based_subscription_storage_factory(std::size_t initial_capacity)
Factory for subscription storage based on sorted std::vector.
const int rc_disp_create_failed
Unable to create a dispatcher.
Definition ret_code.hpp:97
const int rc_layer_not_binded_to_so_env
The layer is not bound to the SObjectizer Environment.
Definition ret_code.hpp:152
message_delivery_mode_t
Possible modes of message/signal delivery.
Definition types.hpp:172
const int rc_coop_define_agent_failed
Cooperation couldn't be registered.
Definition ret_code.hpp:74
priority_t to_priority_t(std::size_t v)
Helper function for conversion from size_t to priority.
Definition priority.hpp:62
void ensure_message_with_actual_data(const Msg *m)
A special checker to guarantee that the message is an instance of the message_t (not signal_t) and ha...
Definition message.hpp:539
agent_context_t operator+(agent_context_t ctx, custom_direct_mbox_factory_t factory)
const int rc_state_nesting_is_too_deep
Nesting of agent states is too deep.
Definition ret_code.hpp:59
SO_5_FUNC timer_thread_unique_ptr_t create_timer_wheel_thread(error_logger_shptr_t logger)
Create timer thread based on timer_wheel mechanism.
Definition timers.cpp:491
const int rc_agent_incompatible_type_conversion
It is impossible to make a cast to that type.
Definition ret_code.hpp:36
const int rc_initial_substate_already_defined
Initial substate for a composite state is already defined.
Definition ret_code.hpp:66
timer_manager_factory_t timer_wheel_manager_factory(unsigned int wheel_size, std::chrono::steady_clock::duration granularity)
Factory for timer_wheel manager with explicitely specified parameters.
Definition timers.hpp:663
const int rc_unable_to_start_extra_layer
Layer initialization is failed.
Definition ret_code.hpp:164
SO_5_FUNC subscription_storage_factory_t default_subscription_storage_factory()
Factory for default subscription storage object.
mbox_type_t
Type of the message box.
Definition mbox.hpp:163
const int rc_negative_value_for_pause
An attempt to use negative value for pause argument for delayed or periodic message/signal.
Definition ret_code.hpp:270
const int rc_prepared_select_is_active_now
An attempt to activate prepared-select when an operation on that prepared-select object is already ac...
Definition ret_code.hpp:418
void ensure_not_signal()
A special compile-time checker to guarantee that the message class is not a signal class.
Definition message.hpp:517
const int rc_msg_chain_overflow
Definition ret_code.hpp:203
const int rc_coop_is_not_in_registered_state
An attempt to do something with coop that is not in registered state.
Definition ret_code.hpp:395
agent_context_t operator+(agent_context_t ctx, message_limit::abort_app_indicator_t< M > limit)
const int rc_mutable_msg_cannot_be_periodic
An attempt to send mutable message as a periodic message.
Definition ret_code.hpp:241
const int rc_cannot_set_stop_guard_when_stop_is_started
An attempt to set up a new stop_guard when the stop operation is already in progress.
Definition ret_code.hpp:259
void operator>>=(agent_t *agent, const state_t &new_state)
A shortcat for switching the agent state.
Definition agent.hpp:3953
constexpr unsigned int max_redirection_deep
Maximum deep of message redirections.
const int rc_no_preallocated_resources_for_agent
There are no resources that must have been in place for an agent in advance.
Definition ret_code.hpp:481
mchain_receive_params_t< mchain_props::msg_count_status_t::undefined > from(mchain_t chain)
A helper function for simplification of creation of mchain_receive_params instance.
Definition mchain.hpp:1540
const int rc_transfer_to_state_loop
A loop in transfer_to_state detected.
Definition ret_code.hpp:337
exception_reaction_t
A reaction of SObjectizer to an exception from agent event.
Definition agent.hpp:65
@ abort_on_exception
Execution of application must be aborted immediatelly.
Definition agent.hpp:67
@ inherit_exception_reaction
Exception reaction should be inherited from SO Environment.
Definition agent.hpp:81
@ ignore_exception
Exception should be ignored and agent should continue its work.
Definition agent.hpp:75
@ deregister_coop_on_exception
Definition agent.hpp:73
@ shutdown_sobjectizer_on_exception
Definition agent.hpp:70
std::enable_if<!message_payload_type< Message >::is_signal >::type send_delayed(Target &&to, std::chrono::steady_clock::duration pause, mhood_t< Message > msg)
A utility function for delayed redirection of a message from existing message hood.
SO_5_FUNC error_logger_shptr_t create_stderr_logger()
A factory for creating error_logger implemenation which uses std::stderr as log stream.
std::enable_if< message_payload_type< Message >::is_signal >::type send_delayed(Target &&to, std::chrono::steady_clock::duration pause, mhood_t< Message >)
A utility function for delayed redirection of a signal from existing message hood.
void ensure_not_mutable_signal()
A special compile-time checker to guarantee that S is not a mutable signal.
Definition message.hpp:563
const int rc_coop_already_destroyed
An attempt to get a pointer to already destroyed cooperation.
Definition ret_code.hpp:384
agent_context_t operator+(agent_context_t ctx, so_5::priority_t agent_priority)
const int rc_agent_name_too_long
Length of an agent name is too large.
Definition ret_code.hpp:519
current_thread_id_t null_current_thread_id()
Get NULL thread id.
const thread_safety_t not_thread_safe
Shorthand for thread unsafety indicator.
Definition types.hpp:62
const int rc_msg_chain_is_full
Attempt to push a message to full message queue.
Definition ret_code.hpp:193
std::enable_if< details::is_agent_method_pointer< details::method_arity::unary, Method_Pointer >::value, details::msg_type_and_handler_pair_t >::type preprocess_agent_event_handler(const mbox_t &mbox, agent_t &agent, Method_Pointer pfn)
Do preprocessing and some verification of event handler and return msg_type_and_handler_pair for it.
priority_t
Definition of supported priorities.
Definition priority.hpp:28
const thread_safety_t thread_safe
Shorthand for thread safety indicator.
Definition types.hpp:69
const int rc_operation_enabled_only_on_agent_working_thread
An attempt to perform an operation which is enabled only on agent's working thread.
Definition ret_code.hpp:44
const int rc_autoshutdown_must_be_enabled
An attempt to launch environment with autoshutdown disabled in conditions where autoshutdown must be ...
Definition ret_code.hpp:227
SO_5_FUNC timer_thread_unique_ptr_t create_timer_heap_thread(error_logger_shptr_t logger, std::size_t initial_heap_capacity)
Create timer thread based on timer_heap mechanism.
Definition timers.cpp:534
const int rc_agent_is_not_the_state_owner
Agent doesn't own this state.
Definition ret_code.hpp:108
const int rc_scenario_must_be_completed
Testing scenario must be completed before an attempt to do the current operation.
Definition ret_code.hpp:367
const int rc_extensible_select_is_active_now
An attempt to modify or activate extensible-select when an operation on that extensible-select object...
Definition ret_code.hpp:410
const int rc_agent_unknown_state
Trying to switch to the unknown state.
Definition ret_code.hpp:30
SO_5_FUNC timer_thread_unique_ptr_t create_timer_list_thread(error_logger_shptr_t logger)
Create timer thread based on timer_list mechanism.
Definition timers.cpp:552
message_mutability_t
A enum with variants of message mutability or immutability.
Definition types.hpp:94
std::thread::id raw_id_from_current_thread_id(const current_thread_id_t &w)
Get the raw thread id from current_thread_id.
SO_5_FUNC timer_manager_unique_ptr_t create_timer_list_manager(error_logger_shptr_t logger, outliving_reference_t< timer_manager_t::elapsed_timers_collector_t > collector)
Create timer thread based on timer_list mechanism.
Definition timers.cpp:639
void send(Target &&to, message_holder_t< Message, Ownership > what)
A version of send function for redirection of a message from exising message_holder instance.
infinite_wait_indication
A type for special marker for infitite waiting on service request or on receive from mchain.
const int rc_trying_to_add_extra_layer_that_already_exists_in_extra_list
The layer is already bound to the SObjectizer Environment as an extra layer.
Definition ret_code.hpp:161
const int rc_several_limits_for_one_message_type
An attempt to define several limits for one message type.
Definition ret_code.hpp:130
const int rc_layer_does_not_exist
A layer with the specified type doesn't exist.
Definition ret_code.hpp:167
const int rc_invalid_time_limit_for_state
Invalid value of time limit for an agent's state.
Definition ret_code.hpp:539
mchain_params_t make_unlimited_mchain_params()
Create parameters for size-unlimited mchain.
Definition mchain.hpp:820
const int rc_agent_to_disp_binding_failed
Binding of agent to dispatcher failed.
Definition ret_code.hpp:81
thread_safety_t
Thread safety indicator.
Definition types.hpp:50
@ unsafe
Not thread safe.
@ safe
Thread safe.
const int rc_priority_quote_illegal_value
Illegal value of quote for a priority.
Definition ret_code.hpp:174
timer_thread_factory_t timer_wheel_factory()
Factory for timer_wheel thread with default parameters.
Definition timers.hpp:307
void close_drop_content(Exceptions_Control exceptions_control, const mchain_t &ch) noexcept(noexcept(details::should_terminate_if_throws_t< Exceptions_Control >::value))
Helper function for closing a message chain with dropping all its content.
Definition mchain.hpp:666
timer_manager_factory_t timer_list_manager_factory()
Factory for timer_list manager with default parameters.
Definition timers.hpp:737
const int rc_several_handlers_for_one_message_type
Attempt to define several handlers for one msg_type.
Definition ret_code.hpp:206
SO_5_FUNC subscription_storage_factory_t hash_table_based_subscription_storage_factory()
Factory for default subscription storage based on std::unordered_map.
const int rc_msg_chain_doesnt_support_subscriptions
Attempt to make subscription for message chain.
Definition ret_code.hpp:196
intrusive_ptr_t< Derived > make_agent_ref(Derived *agent)
Helper function template for the creation of smart pointer to an agent.
Definition agent.hpp:3400
SO_5_FUNC timer_manager_unique_ptr_t create_timer_wheel_manager(error_logger_shptr_t logger, outliving_reference_t< timer_manager_t::elapsed_timers_collector_t > collector)
Create timer manager based on timer_wheel mechanism.
Definition timers.cpp:568
SO_5_FUNC timer_manager_unique_ptr_t create_timer_wheel_manager(error_logger_shptr_t logger, outliving_reference_t< timer_manager_t::elapsed_timers_collector_t > collector, unsigned int wheel_size, std::chrono::steady_clock::duration granuality)
Create timer manager based on timer_wheel mechanism.
Definition timers.cpp:583
const infinite_wait_indication infinite_wait
A special indicator for infinite waiting on service request or on receive from mchain.
decltype(auto) introduce_child_coop(agent_t &owner, Args &&... args)
A simple way for creating and registering child cooperation.
const int rc_stored_msg_inspection_result_not_found
There is no stored msg inspection result in the testing scenario.
Definition ret_code.hpp:526
timer_thread_factory_t timer_list_factory()
Factory for timer_list thread with default parameters.
Definition timers.hpp:385
message_kind_t
A enum with variants of message kinds.
Definition types.hpp:109
@ user_type_message
Message is an user type message.
@ enveloped_msg
Message is an envelope with some other message inside.
agent_context_t operator+(agent_context_t ctx, message_limit::drop_indicator_t< M > limit)
const int rc_empty_agent_name
Name for an agent can't be empty.
Definition ret_code.hpp:512
constexpr terminate_if_throws_t terminate_if_throws
Value that indicates that an exception leads to the termination of the whole application.
event_queue_hook_unique_ptr_t make_empty_event_queue_hook_unique_ptr()
Helper function for creation of empty unique_ptr for event_queue_hook.
const int rc_agent_deactivated
Agent can't change state because the agent is already deactivated.
Definition ret_code.hpp:432
no_wait_indication
A type for special marker for no waiting on service request or on receive from mchain.
SO_5_FUNC void swap(name_for_agent_t &a, name_for_agent_t &b) noexcept
Definition agent.cpp:150
timer_id_t send_periodic(Target &&target, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period, Args &&... args)
A utility function for creating and delivering a periodic message to the specified destination.
std::enable_if< is_signal< M >::value, mhood_t< immutable_msg< M > > >::type to_immutable(mhood_t< mutable_msg< M > >)
Definition mhood.hpp:607
const int rc_stored_state_name_not_found
There is no stored state name in the testing scenario.
Definition ret_code.hpp:374
mbox_id_t null_mbox_id()
Default value for null mbox_id.
Definition types.hpp:39
std::enable_if<!is_signal< M >::value, mhood_t< immutable_msg< M > > >::type to_immutable(mhood_t< mutable_msg< M > > msg)
Transform mutable message instance into immutable.
Definition mhood.hpp:597
void send(Target &&to, Args &&... args)
A utility function for creating and delivering a message or a signal.
const int rc_another_state_switch_in_progress
An attempt to switch agent state when another switch operation is in progress.
Definition ret_code.hpp:216
std::enable_if< is_signal< Message >::value, timer_id_t >::type send_periodic(Target &&target, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period, mhood_t< Message >)
A utility function for periodic redirection of a signal from existing message hood.
work_thread_activity_tracking_t
Values for dispatcher's work thread activity tracking.
Definition types.hpp:75
@ unspecified
Tracking mode is specified elsewhere.
const no_wait_indication no_wait
A special indicator for no waiting on service request or on receive from mchain.
const int rc_unable_to_define_new_step
New step can't be defined if testing scenario is already started or finished.
Definition ret_code.hpp:359
const int rc_msg_tracing_disabled
Message delivery tracing is disabled and cannot be used.
Definition ret_code.hpp:182
message_ownership_t
Type of ownership of a message instance inside message_holder.
const int rc_unable_to_register_coop_during_shutdown
It is impossible to register cooperation during SObjectizer Environment shutdown.
Definition ret_code.hpp:89
intrusive_ptr_t(std::unique_ptr< T >) -> intrusive_ptr_t< T >
coop_unique_holder_t create_child_coop(coop_handle_t parent, Args &&... args)
A simple way for creating child cooperation when there is a reference to the parent cooperation objec...
msink_t SO_5_FUNC wrap_to_msink(const mbox_t &mbox, priority_t sink_priority=prio::p0)
Helper for wrapping an existing mbox into message_sink.
Definition mbox.cpp:109
prepared_receive_t< sizeof...(Handlers) > prepare_receive(const mchain_receive_params_t< Msg_Count_Status > &params, Handlers &&... handlers)
Create parameters for receive function to be used later.
Definition mchain.hpp:1990
delivery_possibility_t
Result of checking delivery posibility.
Definition mbox.hpp:39
const int rc_no_initial_substate
An attempt to change agent state to a new composite state which have no initial state defined.
Definition ret_code.hpp:52
const int rc_unable_to_join_thread_by_itself
An attempt to call join() from the joinable thread itself.
Definition ret_code.hpp:402
timer_manager_factory_t timer_heap_manager_factory(std::size_t initial_heap_capacity)
Factory for timer_heap manager with explicitely specified parameters.
Definition timers.hpp:711
SO_5_FUNC subscription_storage_factory_t adaptive_subscription_storage_factory(std::size_t threshold, const subscription_storage_factory_t &small_storage_factory, const subscription_storage_factory_t &large_storage_factory)
Factory for adaptive subscription storage.
const int rc_agent_has_no_cooperation
Agent is not bound to a cooperation.
Definition ret_code.hpp:33
const int rc_null_message_data
Null message data.
Definition ret_code.hpp:144
const int rc_illegal_subscriber_for_mpsc_mbox
An attempt to create illegal subscription to mpsc_mbox.
Definition ret_code.hpp:115
const int rc_msg_chain_is_empty
Attempt to get message from empty message queue.
Definition ret_code.hpp:190
outliving_reference_t< const T > outliving_const(T const &r)
Make outliving_reference wrapper for const reference.
decltype(auto) introduce_child_coop(coop_handle_t parent, Args &&... args)
A simple way for creating and registering child cooperation when there is a reference to parent coop.
const int rc_unknown_exception_type
An exception of unknown type is caught.
Definition ret_code.hpp:556
void ensure_signal()
A special compile-time checker to guarantee that the Msg is derived from the signal_t.
Definition message.hpp:584
timer_thread_factory_t timer_wheel_factory(unsigned int wheel_size, std::chrono::steady_clock::duration granularity)
Factory for timer_wheel thread with explicitely specified parameters.
Definition timers.hpp:322
std::enable_if<!is_signal< Message >::value, timer_id_t >::type send_periodic(Target &&target, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period, mhood_t< Message > mhood)
A utility function for delivering a periodic from an existing message hood.
void ensure_classical_message()
A special compile-time checker to guarantee that Msg is derived from message_t.
Definition message.hpp:607
SO_5_FUNC subscription_storage_factory_t vector_based_subscription_storage_factory(std::size_t initial_capacity)
Factory for subscription storage based on unsorted std::vector.
timer_thread_factory_t timer_heap_factory()
Factory for timer_heap thread with default parameters.
Definition timers.hpp:349
transformed_message_t< Msg > make_transformed(mbox_t mbox, Args &&... args)
Helper function for creation of an instance of transformed_message_t.
disp_binder_shptr_t make_default_disp_binder(environment_t &env)
Create an instance of the default dispatcher binder.
const int rc_msg_chain_doesnt_support_delivery_filters
Attempt to set delivery_filter for message chain.
Definition ret_code.hpp:199
const int rc_environment_error
so_environment launch is failed.
Definition ret_code.hpp:24
timer_manager_factory_t timer_heap_manager_factory()
Factory for timer_heap manager with default parameters.
Definition timers.hpp:693
outliving_reference_t< const T > outliving_const(outliving_reference_t< T > r)
Make outliving_reference wrapper for const reference.
SO_5_FUNC subscription_storage_factory_t map_based_subscription_storage_factory()
Factory for subscription storage based on std::map.
const int rc_empty_name
The empty name doesn't allowed.
Definition ret_code.hpp:532
const int rc_unexpected_error
Unclassified error.
Definition ret_code.hpp:559
SO_5_FUNC subscription_storage_factory_t adaptive_subscription_storage_factory(std::size_t threshold)
Factory for adaptive subscription storage.
agent_context_t operator+(environment_t &env, Option arg)
A plus operator for creating agent_context object from a reference to Environment and single agent tu...
agent_context_t operator+(agent_context_t ctx, message_limit::redirect_indicator_t< M, L > limit)
SO_5_FUNC timer_manager_unique_ptr_t create_timer_heap_manager(error_logger_shptr_t logger, outliving_reference_t< timer_manager_t::elapsed_timers_collector_t > collector)
Create timer manager based on timer_heap mechanism.
Definition timers.cpp:605
timer_manager_factory_t timer_wheel_manager_factory()
Factory for timer_wheel manager with default parameters.
Definition timers.hpp:644
coop_unique_holder_t create_child_coop(agent_t &owner, Args &&... args)
A simple way for creating child cooperation.
void send_delayed(Target &&target, std::chrono::steady_clock::duration pause, Args &&... args)
A utility function for creating and delivering a delayed message to the specified destination.
constexpr exceptions_enabled_t exceptions_enabled
Value that indicates that exceptions are enabled.
timer_id_t send_periodic(Target &&target, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period, message_holder_t< Message, Ownership > what)
A version of send_periodic function for redirection of a message from exising message_holder instance...
SO_5_FUNC timer_thread_unique_ptr_t create_timer_wheel_thread(error_logger_shptr_t logger, unsigned int wheel_size, std::chrono::steady_clock::duration granuality)
Create timer thread based on timer_wheel mechanism.
Definition timers.cpp:503
agent_context_t operator+(agent_context_t ctx, message_limit::log_then_abort_app_indicator_t< M, L > limit)
agent_context_t operator+(agent_context_t ctx, subscription_storage_factory_t factory)
timer_thread_factory_t timer_heap_factory(std::size_t initial_heap_capacity)
Factory for timer_heap thread with explicitely specified parameters.
Definition timers.hpp:364
const int rc_attempt_to_cast_to_envelope_on_nullptr
An attempt to cast message to message envelope when a pointer to message is NULL.
Definition ret_code.hpp:351
const int rc_evt_handler_already_provided
A handler for that event/mbox/state is already registered.
Definition ret_code.hpp:105
agent_context_t operator+(agent_context_t ctx, name_for_agent_t agent_name)
const int rc_mutable_msg_cannot_be_delivered_via_mpmc_mbox
An attempt to deliver mutable message via MPMC mbox.
Definition ret_code.hpp:234
std::enable_if< details::lambda_traits::is_lambda< Lambda >::value, details::msg_type_and_handler_pair_t >::type preprocess_agent_event_handler(const mbox_t &mbox, agent_t &, Lambda &&lambda)
Do preprocessing and some verification of event handler and return msg_type_and_handler_pair for it.
const int rc_trying_to_add_extra_layer_that_already_exists_in_default_list
The layer is already bound to the SObjectizer Environment as a default layer.
Definition ret_code.hpp:158
event_handler_kind_t
Kind of an event handler.
Definition types.hpp:154
SO_5_FUNC event_exception_logger_unique_ptr_t create_std_event_exception_logger()
Create the default exception logger.
const int rc_disp_binder_already_set_for_agent
The dispatcher binder is already set for the agent.
Definition ret_code.hpp:492
void close_retain_content(Exceptions_Control exceptions_control, const mchain_t &ch) noexcept(noexcept(details::should_terminate_if_throws_t< Exceptions_Control >::value))
Helper function for closing a message chain with retaining all its content.
Definition mchain.hpp:708
std::enable_if<!is_signal< Message >::value >::type send(Target &&to, mhood_t< Message > what)
A version of send function for redirection of a message from exising message hood.
current_thread_id_t query_current_thread_id()
Get the ID of the current thread.
SO_5_FUNC queue_locks_defaults_manager_unique_ptr_t make_defaults_manager_for_simple_locks()
A factory for queue_locks_defaults_manager with generators for simple locks.
std::enable_if< is_signal< Message >::value >::type send(Target &&to, mhood_t< Message >)
A version of send function for redirection of a signal from exising message hood.
SO_5_FUNC timer_thread_unique_ptr_t create_timer_heap_thread(error_logger_shptr_t logger)
Create timer thread based on timer_heap mechanism.
Definition timers.cpp:523
const int rc_nullptr_as_delivery_filter_pointer
nullptr can't be passed as delivery_filter.
Definition ret_code.hpp:454
const int rc_not_implemented
Feature or method has no implementation yet.
Definition ret_code.hpp:546
const int rc_message_has_no_limit_defined
An attempt to create subscription to message without predefined limit for that message type.
Definition ret_code.hpp:123
const int rc_negative_value_for_period
An attempt to use negative value for period argument for periodic message/signal.
Definition ret_code.hpp:280
outliving_reference_t< T > outliving_mutable(T &r)
Make outliving_reference wrapper for mutable reference.
const int rc_mpsc_mbox_expected
An instance of MPSC mbox is expected as custom direct mbox.
Definition ret_code.hpp:443
transformed_message_t< Msg > make_transformed(mbox_t mbox, message_holder_t< Msg, Ownership > msg_holder)
Helper function for creation of an instance of transformed_message_t.
mchain_receive_result_t receive(const prepared_receive_t< Handlers_Count > &prepared)
A receive operation to be done on previously prepared receive params.
Definition mchain.hpp:2033
const int rc_subscription_to_mutable_msg_from_mpmc_mbox
An attempt to make subscription on mutable message from MPMC mbox.
Definition ret_code.hpp:251
mchain_receive_result_t receive(const mchain_receive_params_t< Msg_Count_Status > &params, Handlers &&... handlers)
Advanced version of receive from mchain.
Definition mchain.hpp:1828
const int rc_trying_to_add_nullptr_extra_layer
Unable to bind a layer by the null pointer to it.
Definition ret_code.hpp:155
mchain_params_t make_limited_without_waiting_mchain_params(std::size_t max_size, mchain_props::memory_usage_t memory_usage, mchain_props::overflow_reaction_t overflow_reaction)
Create parameters for size-limited mchain without waiting on overflow.
Definition mchain.hpp:843
mchain_params_t make_limited_with_waiting_mchain_params(std::size_t max_size, mchain_props::memory_usage_t memory_usage, mchain_props::overflow_reaction_t overflow_reaction, mchain_props::duration_t wait_timeout)
Create parameters for size-limited mchain with waiting on overflow.
Definition mchain.hpp:890
void send_delayed(Target &&to, std::chrono::steady_clock::duration pause, message_holder_t< Message, Ownership > msg)
A version of send_delayed function for redirection of a message from exising message_holder instance.
agent_context_t operator+(agent_context_t ctx, message_limit::transform_indicator_t< M > limit)
const int rc_no_disp_binder_for_agent
The dispatcher binder is not set for the agent yet.
Definition ret_code.hpp:505
Type for case when agent has user-provided name.
Type for case when agent has no user-provided name.
SO_5_FUNC std::array< char, c_string_size > make_c_string() const noexcept
Make a c-string with text representation of a value.
Definition agent.cpp:39
static constexpr std::string_view c_string_prefix
Prefix to be used for string representation.
static constexpr std::size_t c_string_size
static constexpr std::string_view c_string_suffix
Suffix to be used for string representation.
void operator()(const pointer_only_t &v) const
void operator()(const actual_name_t &v) const
std::string operator()(const pointer_only_t &v) const
std::string operator()(const actual_name_t &v) const
Type of user resource deleter.
Definition coop.hpp:983
A simple metafunction that always "returns" false.
static constexpr const bool value
A helper template for create an argument for event handler in the case when argument is passed as val...
Basic part of handlers_bunch implementation.
static void prepare_handlers(msg_type_and_handler_pair_t *left, msg_type_and_handler_pair_t *right)
Preparation of message handlers vector.
static SO_5_FUNC bool find_and_use_handler(const msg_type_and_handler_pair_t *left, const msg_type_and_handler_pair_t *right, const std::type_index &msg_type, message_ref_t &message)
Find and exec message handler.
Helper for showing only part of long string.
length_limited_string(const std::string_view what, std::size_t limit)
Helper for showing pointer value.
Check whether T is a non-static member function pointer.
A detector of lambda argument type if the checked type is lambda.
A detector that type is a lambda or functional object.
Detector of plain type without const/volatile modifiers.
static R call_with_arg(R(*l)(M), M m)
Helper for calling a lambda.
static R call_with_arg(R(*l)(M), M m)
Helper for calling a lambda.
static R call_without_arg(L l)
Helper for calling a lambda.
static R call_with_arg(L l, M m)
Helper for calling a lambda.
Detector of lambda result and argument type.
static std::unique_ptr< E > make(Args &&... args)
Definition message.hpp:803
A helper template to detect type of message from the format of an event handler.
A meta-function for selection of type of accessors mixin.
A meta-function for selection a base of message_holder implementation in compile-time.
static const constexpr message_mutability_t mutability
Definition message.hpp:414
static const constexpr message_mutability_t mutability
Definition message.hpp:425
Detector of message type traits in dependency of message immutability or mutability.
Definition message.hpp:398
static const constexpr message_mutability_t mutability
Definition message.hpp:403
A special detector of message immutability/mutability.
Definition mhood.hpp:442
static constexpr const message_mutability_t mutability
Definition mhood.hpp:443
A special selector of message hood type.
Definition mhood.hpp:425
static constexpr const mhood_type_t mhood_type
Definition mhood.hpp:426
bool operator<(const msg_type_and_handler_pair_t &o) const
Comparison (strictly less than).
msg_type_and_handler_pair_t(std::type_index msg_type)
Constructor for the case when only msg_type is known.
friend void swap(msg_type_and_handler_pair_t &a, msg_type_and_handler_pair_t &b) noexcept
Swap operation.
msg_type_and_handler_pair_t(const msg_type_and_handler_pair_t &o)
Copy constructor.
msg_type_and_handler_pair_t & operator=(msg_type_and_handler_pair_t &&o) noexcept
Move operator.
std::type_index m_msg_type
Type of a message or signal.
msg_type_and_handler_pair_t(msg_type_and_handler_pair_t &&o) noexcept
Move constructor.
event_handler_method_t m_handler
A handler for processing this message or signal.
msg_type_and_handler_pair_t(std::type_index msg_type, event_handler_method_t handler, message_mutability_t mutability)
Initializing constructor.
bool operator==(const msg_type_and_handler_pair_t &o) const
Comparison (strictly equal).
msg_type_and_handler_pair_t & operator=(const msg_type_and_handler_pair_t &o)
Copy operator.
message_mutability_t m_mutability
What message is expected by handler: mutable or immutable.
static void exec(Main_Action main_action, rollbacker_t< Rollback_Action > &rollback)
static Result exec(Main_Action main_action, rollbacker_t< Rollback_Action > &rollback)
Statistical data for run-time monitoring of coop repository content.
std::size_t m_total_coop_count
Count of cooperations inside the environment.
std::size_t m_final_dereg_coop_count
Count of coops waiting for the final deregistration.
Internal details of SObjectizer Environment object.
Type that indicates that exceptions are enabled.
A description of event execution demand.
mbox_id_t m_mbox_id
ID of mbox.
void call_handler(current_thread_id_t thread_id)
Helper method to simplify demand execution.
demand_handler_pfn_t m_demand_handler
Demand handler.
agent_t * m_receiver
Receiver of demand.
message_ref_t m_message_ref
Event incident.
execution_demand_t() noexcept
Default constructor.
const message_limit::control_block_t * m_limit
Optional message limit for that message.
execution_demand_t(agent_t *receiver, const message_limit::control_block_t *limit, mbox_id_t mbox_id, std::type_index msg_type, message_ref_t message_ref, demand_handler_pfn_t demand_handler) noexcept
std::type_index m_msg_type
Type of the message.
A helper class for temporary setting and then dropping the ID of the current working thread.
Definition agent.hpp:474
working_thread_id_sentinel_t(so_5::current_thread_id_t &id_var, so_5::current_thread_id_t value_to_set)
Definition agent.hpp:477
value_t(delivery_filter_unique_ptr_t filter, so_5::outliving_reference_t< abstract_message_sink_t > sink)
delivery_filter_unique_ptr_t m_filter
Delivery filter.
std::reference_wrapper< abstract_message_sink_t > m_sink
Message sink for that the filter was set.
Information about event_handler and its properties.
thread_safety_t m_thread_safety
Is event handler thread safe or not.
event_handler_method_t m_method
Method for handling event.
event_handler_data_t(event_handler_method_t method, thread_safety_t thread_safety, event_handler_kind_t kind)
event_handler_kind_t m_kind
Kind of this event handler.
static void send_delayed(const so_5::mbox_t &to, std::chrono::steady_clock::duration pause)
static timer_id_t send_periodic(const so_5::mbox_t &to, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period)
static auto make_instance(Args &&... args)
static void send(const so_5::mbox_t &to, Args &&... args)
static void send_delayed(const so_5::mbox_t &to, std::chrono::steady_clock::duration pause, Args &&... args)
static timer_id_t send_periodic(const so_5::mbox_t &to, std::chrono::steady_clock::duration pause, std::chrono::steady_clock::duration period, Args &&... args)
Base class for a mchain for the case when message delivery tracing is disabled.
void trace_demand_drop_on_close(const abstract_message_chain_t &, const mchain_props::demand_t &)
void trace_extracted_demand(const abstract_message_chain_t &, const mchain_props::demand_t &)
Base class for a mbox for the case when message delivery tracing is disabled.
Helper class to be used as a comparator for msinks.
bool operator()(const msink_t &a, const msink_t &b) const noexcept
static std::pair< const abstract_sink_owner_t *, so_5::priority_t > safe_get_pair(const msink_t &from) noexcept
Helper class to rollback message count change in case of an exception.
decrement_on_exception_t(const so_5::message_limit::control_block_t *limit)
std::reference_wrapper< abstract_message_sink_t > m_message_sink
Message sink used for subscription.
subscr_info_t(mbox_t mbox, std::type_index msg_type, abstract_message_sink_t &message_sink, const state_t &state, const event_handler_method_t &method, thread_safety_t thread_safety, event_handler_kind_t handler_kind)
A helper function to call appropriate constructor of resulting type in dependence of message or signa...
static Result make(mbox_t mbox, Args &&... args)
Create a message instance.
Helper for marking initial substate of composite state.
Definition state.hpp:57
initial_substate_of(state_t &parent_state)
Definition state.hpp:60
A helper class for checking that message is a classical message derived from message_t class.
Definition message.hpp:480
A helper class for checking that message is a mutable message.
Definition message.hpp:496
A helper class for checking that message is a signal.
Definition message.hpp:463
A helper for detection presence of message of user type.
Definition message.hpp:443
const mbox_t & m_mbox
Mbox to which message will be delivered.
const message_ref_t & m_msg
Message to be sent after timeout.
std::chrono::steady_clock::duration m_period
Period of the delivery repetition for periodic messages.
std::chrono::steady_clock::duration m_pause
Timeout before the first delivery.
const std::type_index & m_msg_type
Message type.
const mbox_t & m_mbox
Mbox to which message will be delivered.
const std::type_index & m_msg_type
Message type.
std::chrono::steady_clock::duration m_pause
Timeout before the delivery.
const message_ref_t & m_msg
Message to be sent after timeout.
An information which is necessary for creation of a new mbox.
mbox_id_t m_id
ID for a new mbox.
outliving_reference_t< msg_tracing::holder_t > m_tracer
Stuff to be used for message delivery tracing.
mbox_creation_data_t(outliving_reference_t< environment_t > env, mbox_id_t id, outliving_reference_t< msg_tracing::holder_t > tracer)
Initializing constructor.
outliving_reference_t< environment_t > m_env
Environment for which the mbox is created.
Description of one demand in message chain.
Definition mchain.hpp:144
friend void swap(demand_t &a, demand_t &b) noexcept
Swap operation.
Definition mchain.hpp:164
std::type_index m_msg_type
Type of the message.
Definition mchain.hpp:146
demand_t()
Default constructor.
Definition mchain.hpp:151
so_5::message_ref_t m_message_ref
Event incident.
Definition mchain.hpp:148
demand_t(std::type_index msg_type, so_5::message_ref_t message_ref)
Initializing constructor.
Definition mchain.hpp:155
Container of parameters for receive() function.
Definition mchain.hpp:1413
adv_receive_data_t()=default
Default constructor.
mchain_t m_chain
A chain to be used in receive operation.
Definition mchain.hpp:1415
adv_receive_data_t(mchain_t chain)
Initializing constructor.
Definition mchain.hpp:1421
std::size_t m_to_extract
Minimal count of messages to be extracted.
Definition mchain.hpp:1054
chain_closed_handler_t m_chain_closed_handler
Optional chain-closed handler.
Definition mchain.hpp:1073
std::size_t m_to_handle
Minimal count of messages to be handled.
Definition mchain.hpp:1059
stop_predicate_t m_stop_predicate
Optional stop-predicate.
Definition mchain.hpp:1070
mchain_props::duration_t m_total_time
Total time for all work of advanced receive.
Definition mchain.hpp:1066
mchain_props::duration_t m_empty_timeout
Timeout for waiting on empty queue.
Definition mchain.hpp:1062
Message limit with reaction 'abort the application'.
const unsigned int m_limit
Max count of waiting messages.
abort_app_indicator_t(unsigned int limit)
Initializing constructor.
A control block for one message limit.
Definition message.hpp:976
action_t m_action
Limit overflow reaction.
Definition message.hpp:984
std::atomic_uint m_count
The current count of the messages of that type.
Definition message.hpp:981
control_block_t(unsigned int limit, action_t action)
Initializing constructor.
Definition message.hpp:987
unsigned int m_limit
Limit value.
Definition message.hpp:978
static const control_block_t * none()
A special indicator about absence of control_block.
Definition message.hpp:1023
control_block_t & operator=(const control_block_t &o)
Copy operator.
Definition message.hpp:1009
static void decrement(const control_block_t *limit)
Definition message.hpp:1028
control_block_t(const control_block_t &o)
Copy constructor.
Definition message.hpp:997
A description of one message limit.
std::type_index m_msg_type
Type of message.
description_t(std::type_index msg_type, unsigned int limit, action_t action)
Initializing constructor.
unsigned int m_limit
Max count of waiting messages.
action_t m_action
Reaction to overload.
Message limit with reaction 'drop new message'.
drop_indicator_t(unsigned int limit)
Initializing constructor.
const unsigned int m_limit
Max count of waiting messages.
static void call(const overlimit_context_t &ctx, L action)
Helper class for calling pre-abort action.
static void call(const overlimit_context_t &ctx, L action)
Helper class for calling pre-abort action.
Message limit with reaction 'abort the application' and the possibility to call additional lambda bef...
const L m_lambda
Lambda for some last actions.
const unsigned int m_limit
Max count of waiting messages.
log_then_abort_app_indicator_t(unsigned int limit, L lambda)
Initializing constructor.
A mixin with message limit definition methods.
static drop_indicator_t< Msg > limit_then_drop(unsigned int limit)
A helper function for creating drop_indicator.
static redirect_indicator_t< Msg, Lambda > limit_then_redirect(unsigned int limit, Lambda dest_getter)
A helper function for creating redirect_indicator.
static transform_indicator_t< Source > limit_then_transform(unsigned int limit, Lambda &&transformator)
A helper function for creating transform_indicator.
static log_then_abort_app_indicator_t< M, L > limit_then_abort(unsigned int limit, L lambda)
A helper function for creating log_then_abort_app_indicator.
static abort_app_indicator_t< Msg > limit_then_abort(unsigned int limit)
A helper function for creating abort_app_indicator.
static auto limit_then_redirect(unsigned int limit, mbox_t destination)
A helper function for creating redirect_indicator.
static transformed_message_t< Msg > make_transformed(mbox_t mbox, Args &&... args)
Helper method for creating message transformation result.
static auto limit_then_transform(unsigned int limit, Lambda &&transformator)
A helper function for creating transform_indicator.
Description of context for overlimit action.
Definition message.hpp:895
const message_delivery_mode_t m_delivery_mode
Delivery mode for message delivery attempt.
Definition message.hpp:907
overlimit_context_t(mbox_id_t mbox_id, message_delivery_mode_t delivery_mode, const agent_t &receiver, const control_block_t &limit, unsigned int reaction_deep, const std::type_index &msg_type, const message_ref_t &message, const impl::action_msg_tracer_t *msg_tracer)
Initializing constructor.
Definition message.hpp:937
const mbox_id_t m_mbox_id
ID of mbox which is used for message delivery.
Definition message.hpp:901
const control_block_t & m_limit
Control block for message limit.
Definition message.hpp:913
const unsigned int m_reaction_deep
The current deep of overlimit reaction recursion.
Definition message.hpp:916
const agent_t & m_receiver
Receiver of the message (or enveloped message).
Definition message.hpp:910
const std::type_index & m_msg_type
Type of message to be delivered.
Definition message.hpp:919
const message_ref_t & m_message
A message (or enveloped message) to be delivered.
Definition message.hpp:922
const impl::action_msg_tracer_t * m_msg_tracer
An optional pointer to tracer object for message delivery tracing.
Definition message.hpp:933
Indication that a message must be redirected on overlimit.
Lambda m_destination_getter
A lambda/functional object which returns mbox for redirection.
const unsigned int m_limit
Max count of waiting messages.
redirect_indicator_t(unsigned int limit, Lambda destination_getter)
Initializing constructor.
An indicator of transform reaction on message overlimit.
transform_indicator_t(unsigned int limit, action_t action)
Initializing constructor.
static constexpr message_mutability_t mutability()
Helper for getting message mutability flag.
Definition message.hpp:762
static payload_type & payload_reference(message_t &msg)
Helper for getting a const reference to payload part.
Definition message.hpp:753
static constexpr const bool is_signal
Is it a signal type or message type.
Definition message.hpp:716
static payload_type * extract_payload_ptr(message_ref_t &msg)
Helper for extraction of pointer to payload part.
Definition message.hpp:732
static envelope_type * extract_envelope_ptr(message_ref_t &msg)
Helper for extraction of pointer to envelope part.
Definition message.hpp:745
static std::type_index subscription_type_index()
Type ID for subscription.
Definition message.hpp:720
Implementation details for message_payload_type.
Definition message.hpp:626
static constexpr message_mutability_t mutability()
Helper for getting message mutability flag.
Definition message.hpp:684
static payload_type & payload_reference(message_t &msg)
Helper for getting a const reference to payload part.
Definition message.hpp:676
static envelope_type * extract_envelope_ptr(message_ref_t &msg)
Helper for extraction of pointer to envelope part.
Definition message.hpp:668
static std::type_index subscription_type_index()
Type ID for subscription.
Definition message.hpp:642
static constexpr const bool is_signal
Is it a signal type or message type.
Definition message.hpp:638
static payload_type * extract_payload_ptr(message_ref_t &msg)
Helper for extraction of pointer to payload part.
Definition message.hpp:657
A helper class for detection of payload type of message.
Definition message.hpp:783
An information about compound description of message-related action.
const char * m_first
The first part of the description.
const char * m_second
The second part of the description.
An information about a message instance.
const void * m_envelope
A pointer to envelope.
message_mutability_t m_mutability
Information about message mutability.
An information about message source.
mbox_id_t m_id
ID of mbox or mchain.
msg_source_type_t m_type
Type of message source.
Helper type with method to be mixed into agent class.
static name_for_agent_t name_for_agent(std::string_view name)
A helper factory for making name_for_agent_t instance.
time_limit_t(duration_t limit, const state_t &state_to_switch)
Definition agent.cpp:207
void set_up_limit_for_agent(agent_t &agent, const state_t &current_state) noexcept
Definition agent.cpp:215
const state_t & m_state_to_switch
Definition agent.cpp:202
void drop_limit_for_agent(agent_t &agent, const state_t &current_state) noexcept
Definition agent.cpp:247
Helper for marking a substate of composite state.
Definition state.hpp:89
state_t * m_parent_state
Definition state.hpp:90
substate_of(state_t &parent_state)
Definition state.hpp:92
Type that indicates that an exception leads to the termination of the whole application.
Statistics for run-time monitoring.
Definition timers.hpp:120
std::size_t m_periodic_count
Quantity of periodic timers.
Definition timers.hpp:125
std::size_t m_single_shot_count
Quantity of single-shot timers.
Definition timers.hpp:122
Template class for representing object of user type as a message.
Definition message.hpp:315
user_type_message_t(T &&o)
Initialization from temporary T object.
Definition message.hpp:340
kind_t so5_message_kind() const noexcept override
Detect the kind of the message.
Definition message.hpp:346
user_type_message_t(T &o)
Initialization from non-const T object.
Definition message.hpp:335
T m_payload
Instance of user message.
Definition message.hpp:321
user_type_message_t(const T &o)
Initialization from const T object.
Definition message.hpp:330
user_type_message_t(Args &&... args)
Initializing constructor.
Definition message.hpp:325
#define SO_5_VERSION_PATCH
Definition version.hpp:45
#define SO_5_VERSION_MAJOR
Definition version.hpp:24
#define SO_5_VERSION_MAKE(major, minor, patch)
Definition version.hpp:58
#define SO_5_VERSION_MINOR
Definition version.hpp:34