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
58 empty()
const noexcept {
return !m_binder; }
80 reset()
noexcept { m_binder.reset(); }
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 )
143 return make_dispatcher( env, data_sources_name_base, disp_params_t{} );
150
151
152
153
154
155
156
157
158
159
160
161
162
163
167 return make_dispatcher( env, std::string_view{} );
An analog of std::lock_guard for MPSC queue lock.
void notify_one() noexcept
An analog of std::unique_lock for MPSC queue lock.
void wait_for_notify() noexcept
Alias for namespace with traits of event queue.
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.
Interface for dispatcher binders.
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.
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)
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.
All stuff related to run-time monitoring and statistics.
Private part of message limit implementation.
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.
Stats for a work thread activity.