2
3
6
7
8
9
10
11
15#include <so_5/disp/nef_one_thread/params.hpp>
17#include <so_5/declspec.hpp>
19#include <so_5/disp_binder.hpp>
41
42
43
44
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
112 const std::string_view data_sources_name_base,
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
141 const std::string_view data_sources_name_base )
150
151
152
153
154
155
156
157
158
159
160
161
162
163
void so_bind_to_dispatcher(event_queue_t &queue) noexcept
Binding agent to the dispatcher.
An analog of std::lock_guard for MPSC queue lock.
void notify_one() noexcept
lock_guard_t(lock_t &lock)
const lock_factory_t & lock_factory() const
Getter for lock factory.
An analog of std::unique_lock for MPSC queue lock.
void wait_for_notify() noexcept
unique_lock_t(lock_t &lock)
Alias for namespace with traits of event queue.
const queue_traits::queue_params_t & queue_params() const noexcept
Getter for queue parameters.
disp_params_t()=default
Default constructor.
A handle for nef_one_thread dispatcher.
bool operator!() const noexcept
Does this handle contain a reference to dispatcher?
disp_binder_shptr_t binder() const noexcept
Get a binder for that dispatcher.
disp_binder_shptr_t m_binder
Binder for the dispatcher.
bool empty() const noexcept
Is this handle empty?
operator bool() const noexcept
Is this handle empty?
void reset() noexcept
Drop the content of handle.
dispatcher_handle_t() noexcept=default
dispatcher_handle_t(disp_binder_shptr_t binder) noexcept
agent_queue_t(const agent_queue_t &)=delete
agent_queue_t(agent_queue_t &&o)=delete
void push_evt_finish(execution_demand_t demand) noexcept override
Enqueue a demand for evt_finish event.
void push_evt_start(execution_demand_t demand) override
Enqueue a demand for evt_start event.
std::reference_wrapper< demand_queue_t > m_dest_queue
demand_unique_ptr_t m_evt_start_demand
void push(execution_demand_t demand) override
Enqueue new event to the queue.
agent_queue_t & operator=(const agent_queue_t &)=delete
demand_unique_ptr_t m_evt_finish_demand
agent_queue_t(demand_queue_t &dest_queue, demand_unique_ptr_t evt_start_demand, demand_unique_ptr_t evt_finish_demand)
agent_queue_t & operator=(agent_queue_t &&o)=delete
demand_unique_ptr_t remove_head() noexcept
Helper method for deleting queue's head object.
std::size_t size() const
Get the current size of the queue.
~demand_queue_t() noexcept
void push(demand_unique_ptr_t tail_demand)
demand_t * m_head
Head of the queue.
std::atomic< std::size_t > m_size
Current size of the queue.
demand_queue_t(queue_traits::lock_unique_ptr_t lock)
Initializing constructor.
demand_t * m_tail
Tail of the queue.
void stop()
Set the shutdown signal.
demand_unique_ptr_t pop()
bool m_shutdown
Shutdown flag.
queue_traits::lock_unique_ptr_t m_lock
Queue lock.
static dispatcher_handle_t make(disp_binder_shptr_t binder) noexcept
Data source for run-time monitoring of whole dispatcher.
stats::prefix_t m_base_prefix
Basic prefix for data sources.
outliving_reference_t< dispatcher_template_t > m_dispatcher
Dispatcher to work with.
void distribute(const mbox_t &mbox) override
Send appropriate notification about the current value.
disp_data_source_t(const std::string_view name_base, outliving_reference_t< dispatcher_template_t > disp)
void bind(agent_t &agent) noexcept override
Bind agent to dispatcher.
std::mutex m_agent_map_lock
Lock for agent_map protection.
~dispatcher_template_t() noexcept override
void undo_preallocation(agent_t &agent) noexcept override
Undo resources allocation.
Work_Thread m_work_thread
Worker thread for the dispatcher.
void preallocate_resources(agent_t &agent) override
Allocate resources in dispatcher for new agent.
stats::auto_registered_source_holder_t< disp_data_source_t > m_data_source
Data source for run-time monitoring.
agent_map_t m_agents
Agents for those resources are allocated by the dispatcher.
dispatcher_template_t(outliving_reference_t< environment_t > env, const std::string_view name_base, disp_params_t params)
void unbind(agent_t &agent) noexcept override
Unbind agent from dispatcher.
A part of implementation of work thread without activity tracking.
no_activity_tracking_impl_t(queue_traits::lock_unique_ptr_t lock, work_thread_holder_t thread_holder)
A part of implementation of work thread with activity tracking.
so_5::stats::work_thread_activity_stats_t take_activity_stats()
so_5::stats::activity_tracking_stuff::stats_collector_t< so_5::stats::activity_tracking_stuff::internal_lock > m_waiting_stats
Statictics for wait activity.
with_activity_tracking_impl_t(queue_traits::lock_unique_ptr_t lock, work_thread_holder_t thread_holder)
so_5::stats::activity_tracking_stuff::stats_collector_t< so_5::stats::activity_tracking_stuff::internal_lock > m_working_stats
Statictics for work activity.
A worker thread for nef_one_thread dispatcher.
void call_handler(so_5::execution_demand_t &demand)
demand_queue_t & demand_queue() noexcept
demand_unique_ptr_t pop_demand()
so_5::current_thread_id_t thread_id() const
work_thread_template_t(queue_traits::lock_unique_ptr_t lock, work_thread_holder_t thread_holder)
Initializing constructor.
An analog of unique_ptr for abstract_work_thread.
work_thread_holder_t(work_thread_holder_t &&o) noexcept
Interface for dispatcher binders.
stats::repository_t & stats_repository()
Access to repository of data sources for run-time monitoring.
An interface of event queue for agent.
Helper class for indication of long-lived reference via its type.
Base for the case of internal stats lock.
Helper for collecting activity stats.
so_5::stats::activity_stats_t take_stats()
A holder for data-souce that should be automatically registered and deregistered in registry.
A type for storing prefix of data_source name.
An interface of data source.
#define SO_5_THROW_EXCEPTION(error_code, desc)
Some reusable and low-level classes/functions which can be used in public header files.
Various stuff related to MPSC event queue implementation and tuning.
void send_thread_activity_stats(const so_5::mbox_t &, const stats::prefix_t &, work_thread_no_activity_tracking_t &)
dispatcher_handle_t make_dispatcher(environment_t &env)
Create an instance of nef_one_thread dispatcher.
SO_5_FUNC dispatcher_handle_t make_dispatcher(environment_t &env, const std::string_view data_sources_name_base, disp_params_t params)
Create an instance of nef_one_thread dispatcher.
dispatcher_handle_t make_dispatcher(environment_t &env, const std::string_view data_sources_name_base)
Create an instance of nef_one_thread dispatcher.
Reusable components for dispatchers.
work_thread_holder_t acquire_work_thread(const work_thread_factory_mixin_t< Params > ¶ms, environment_t &env)
Helper function for acquiring a new worker thread from an appropriate work thread factory.
so_5::stats::prefix_t make_disp_prefix(const std::string_view disp_type, const std::string_view data_sources_name_base, const void *disp_this_pointer)
Create basic prefix for dispatcher data source names.
std::unique_ptr< Disp_Iface_Type > make_actual_dispatcher(outliving_reference_t< environment_t > env, const std::string_view name_base, Disp_Params_Type disp_params, Args &&...args)
Helper function for creation of dispatcher instance with respect to work thread activity tracking fla...
Details of SObjectizer run-time implementations.
void ensure_join_from_different_thread(current_thread_id_t thread_to_be_joined)
Ensures that join will be called from different thread.
Declarations of messages used by run-time monitoring and statistics.
Predefined suffixes of data-sources.
SO_5_FUNC suffix_t agent_count()
Suffix for data source with count of agents bound to some entity.
SO_5_FUNC suffix_t work_thread_queue_size()
Suffix for data source with count of demands in a working thread event queue.
SO_5_FUNC suffix_t work_thread_activity()
Suffix for data source with work thread activity statistics.
All stuff related to run-time monitoring and statistics.
Private part of message limit implementation.
const int rc_no_preallocated_resources_for_agent
There are no resources that must have been in place for an agent in advance.
void send(Target &&to, Args &&... args)
A utility function for creating and delivering a message or a signal.
current_thread_id_t query_current_thread_id()
Get the ID of the current thread.
outliving_reference_t< T > outliving_mutable(T &r)
Make outliving_reference wrapper for mutable reference.
A single execution demand.
demand_t * m_next
Next demand in the queue.
demand_t()=default
Default constructor.
execution_demand_t m_execution_demand
Execution demand to be used.
demand_t(execution_demand_t &&source)
Initializing constructor.
A common data for all work thread implementations.
demand_queue_t m_queue
Demands queue to work for.
common_data_t(queue_traits::lock_unique_ptr_t lock, work_thread_holder_t thread_holder)
Initializing constructor.
so_5::current_thread_id_t m_thread_id
ID of the work thread.
work_thread_holder_t m_thread_holder
Thread object.
A description of event execution demand.
void call_handler(current_thread_id_t thread_id)
Helper method to simplify demand execution.
A message with value of some quantity.
Information about one work thread activity.
Stats for a work thread activity.
activity_stats_t m_working_stats
Stats for processed events.
activity_stats_t m_waiting_stats
Stats for waiting periods.