2
3
6
7
8
9
10
11
12
14#include <so_5/disp/prio_one_thread/quoted_round_robin/pub.hpp>
16#include <so_5/disp/prio_one_thread/quoted_round_robin/impl/demand_queue.hpp>
17#include <so_5/disp/prio_one_thread/reuse/work_thread.hpp>
19#include <so_5/disp/reuse/actual_work_thread_factory_to_use.hpp>
20#include <so_5/disp/reuse/data_source_prefix_helpers.hpp>
21#include <so_5/disp/reuse/make_actual_dispatcher.hpp>
23#include <so_5/stats/repository.hpp>
24#include <so_5/stats/messages.hpp>
25#include <so_5/stats/std_names.hpp>
27#include <so_5/send_functions.hpp>
55 const so_5::mbox_t & mbox,
57 so_5::disp::prio_one_thread::reuse::work_thread_with_activity_tracking_t<
58 demand_queue_t > & wt )
60 so_5::send< stats::messages::work_thread_activity >(
63 stats::suffixes::work_thread_activity(),
65 wt.take_activity_stats() );
74
75
76
77
78
79
80template<
typename Work_Thread >
83 friend class disp_data_source_t;
88 const std::string_view name_base,
92 params.queue_params().lock_factory()(),
95 so_5::disp::reuse::acquire_work_thread( params, env.get() ),
98 outliving_mutable(env.get().stats_repository()),
100 outliving_mutable(*
this)
103 m_work_thread.start();
108 m_demand_queue.stop();
109 m_work_thread.join();
128 agent_t & agent )
noexcept override
130 const auto priority = agent.so_priority();
132 agent.so_bind_to_dispatcher(
133 m_demand_queue.event_queue_by_priority( priority ) );
135 m_demand_queue.agent_bound( priority );
140 agent_t & agent )
noexcept override
142 const auto priority = agent.so_priority();
144 m_demand_queue.agent_unbound( priority );
149
150
151
152
153
164 const std::string_view name_base,
211 std::size_t agents_count,
212 std::size_t demands_count )
257 make( disp_binder_shptr_t binder )
noexcept
259 return { std::move( binder ) };
271 const std::string_view data_sources_name_base,
278 using dispatcher_no_activity_tracking_t =
279 impl::dispatcher_template_t<
280 work_thread_no_activity_tracking_t< impl::demand_queue_t > >;
282 using dispatcher_with_activity_tracking_t =
283 impl::dispatcher_template_t<
284 work_thread_with_activity_tracking_t< impl::demand_queue_t > >;
286 disp_binder_shptr_t binder = so_5::disp::reuse::make_actual_dispatcher<
288 dispatcher_no_activity_tracking_t,
289 dispatcher_with_activity_tracking_t >(
290 outliving_mutable(env),
291 data_sources_name_base,
295 return impl::dispatcher_handle_maker_t::make( std::move(binder) );
Alias for namespace with traits of event queue.
A handle for prio_one_thread::strictly_ordered dispatcher.
A demand queue for dispatcher with one common working thread and round-robin processing of prioritise...
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.
disp_data_source_t(const std::string_view name_base, outliving_reference_t< dispatcher_template_t > disp)
outliving_reference_t< dispatcher_template_t > m_dispatcher
Dispatcher to work with.
void distribute_value_for_priority(const mbox_t &mbox, priority_t priority, std::size_t quote, std::size_t agents_count, std::size_t demands_count)
void distribute(const mbox_t &mbox) override
Send appropriate notification about the current value.
void undo_preallocation(agent_t &) noexcept override
Undo resources allocation.
dispatcher_template_t(outliving_reference_t< environment_t > env, const std::string_view name_base, disp_params_t params, const quotes_t "es)
void preallocate_resources(agent_t &) override
Allocate resources in dispatcher for new agent.
void unbind(agent_t &agent) noexcept override
Unbind agent from dispatcher.
void bind(agent_t &agent) noexcept override
Bind agent to dispatcher.
~dispatcher_template_t() noexcept override
stats::auto_registered_source_holder_t< disp_data_source_t > m_data_source
Data source for run-time monitoring.
Work_Thread m_work_thread
Working thread for the dispatcher.
demand_queue_t m_demand_queue
Demand queue for the dispatcher.
A storage of quotes for priorities.
Interface for dispatcher binders.
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.
An interface of data source.
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 with round-robin policy of handling prioritized events.
Dispatcher which handles events of different priorities in round-robin maner.
SO_5_FUNC dispatcher_handle_t make_dispatcher(environment_t &env, const std::string_view data_sources_name_base, const quotes_t "es, disp_params_t params)
Create an instance of quoted_round_robin dispatcher.
Reusable code for dispatchers with one working thread for events of all priorities.
Dispatcher with one working thread for events of all priorities.
Reusable components for dispatchers.
All stuff related to run-time monitoring and statistics.
Private part of message limit implementation.
priority_t
Definition of supported priorities.