2
3
6
7
8
9
10
11
13#include <so_5/disp/prio_one_thread/strictly_ordered/pub.hpp>
15#include <so_5/disp/prio_one_thread/strictly_ordered/impl/demand_queue.hpp>
16#include <so_5/disp/prio_one_thread/reuse/work_thread.hpp>
18#include <so_5/disp/reuse/actual_work_thread_factory_to_use.hpp>
19#include <so_5/disp/reuse/data_source_prefix_helpers.hpp>
20#include <so_5/disp/reuse/make_actual_dispatcher.hpp>
22#include <so_5/stats/repository.hpp>
23#include <so_5/stats/messages.hpp>
24#include <so_5/stats/std_names.hpp>
26#include <so_5/send_functions.hpp>
53send_thread_activity_stats(
54 const so_5::mbox_t & mbox,
73
74
75
76
77
78template<
typename Work_Thread >
81 friend class disp_data_source_t;
86 const std::string_view name_base,
96 outliving_mutable(*
this)
124 agent_t & agent )
noexcept override
136 agent_t & agent )
noexcept override
146
147
148
149
160 const std::string_view name_base,
175 std::size_t agents_count = 0;
177 disp.m_demand_queue.handle_stats_for_each_prio(
194 send_thread_activity_stats(
197 disp.m_work_thread );
205 std::size_t agents_count,
206 std::size_t demands_count )
208 std::ostringstream ss;
245 make( disp_binder_shptr_t binder )
noexcept
247 return { std::move( binder )
};
259 const std::string_view data_sources_name_base,
265 using dispatcher_no_activity_tracking_t =
266 impl::dispatcher_template_t<
269 using dispatcher_with_activity_tracking_t =
270 impl::dispatcher_template_t<
275 dispatcher_no_activity_tracking_t
,
276 dispatcher_with_activity_tracking_t
>(
278 data_sources_name_base
,
priority_t so_priority() const noexcept
Get the priority of the agent.
void so_bind_to_dispatcher(event_queue_t &queue) noexcept
Binding agent to the dispatcher.
const lock_factory_t & lock_factory() const
Getter for lock factory.
so_5::stats::work_thread_activity_stats_t take_activity_stats()
so_5::current_thread_id_t thread_id() const
Alias for namespace with traits of event queue.
const queue_traits::queue_params_t & queue_params() const noexcept
Getter for queue parameters.
A handle for prio_one_thread::strictly_ordered dispatcher.
dispatcher_handle_t(disp_binder_shptr_t binder) noexcept
A demand queue with support of demands priorities.
void agent_bound(priority_t priority)
Notification about attachment of yet another agent to the queue.
void stop()
Set the shutdown signal.
void agent_unbound(priority_t priority)
Notification about detachment of an agent from the queue.
demand_queue_t(queue_traits::lock_unique_ptr_t lock)
event_queue_t & event_queue_by_priority(priority_t priority)
Get queue for the priority specified.
static dispatcher_handle_t make(disp_binder_shptr_t binder) noexcept
Data source for run-time monitoring of whole dispatcher.
void distribute_value_for_priority(const mbox_t &mbox, priority_t priority, std::size_t agents_count, std::size_t demands_count)
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.
stats::prefix_t m_base_prefix
Basic prefix for data sources.
disp_data_source_t(const std::string_view name_base, outliving_reference_t< dispatcher_template_t > disp)
void unbind(agent_t &agent) noexcept override
Unbind agent from dispatcher.
demand_queue_t m_demand_queue
Demand queue for the dispatcher.
void bind(agent_t &agent) noexcept override
Bind agent to dispatcher.
dispatcher_template_t(outliving_reference_t< environment_t > env, const std::string_view name_base, disp_params_t params)
void undo_preallocation(agent_t &) noexcept override
Undo resources allocation.
void preallocate_resources(agent_t &) override
Allocate resources in dispatcher for new agent.
Work_Thread m_work_thread
Working thread for the dispatcher.
stats::auto_registered_source_holder_t< disp_data_source_t > m_data_source
Data source for run-time monitoring.
~dispatcher_template_t() noexcept override
Interface for dispatcher binders.
stats::repository_t & stats_repository()
Access to repository of data sources for run-time monitoring.
Helper class for indication of long-lived reference via its type.
A holder for data-souce that should be automatically registered and deregistered in registry.
A type for storing prefix of data_source name.
constexpr const char * c_str() const noexcept
Access to prefix value.
prefix_t(const std::string &value) noexcept(noexcept(value.c_str()))
Initializing constructor.
An interface of data source.
Reusable code for dispatchers with one working thread for events of all priorities.
void send_thread_activity_stats(const so_5::mbox_t &, const stats::prefix_t &, so_5::disp::prio_one_thread::reuse::work_thread_no_activity_tracking_t< demand_queue_t > &)
Implementation details for dispatcher which handles prioritized events in strict order.
Dispatcher which handles events in strict order (from highest priority to lowest).
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 strictly_ordered dispatcher.
Dispatcher with one working thread for events of all priorities.
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...
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.
std::size_t to_size_t(priority_t priority)
Helper function for conversion from priority to size_t.
priority_t
Definition of supported priorities.
void send(Target &&to, Args &&... args)
A utility function for creating and delivering a message or a signal.
outliving_reference_t< T > outliving_mutable(T &r)
Make outliving_reference wrapper for mutable reference.
Statistic about one subqueue.
std::size_t m_agents_count
std::size_t m_demands_count
A message with value of some quantity.
Information about one work thread activity.