2
3
6
7
8
12#include <so_5/declspec.hpp>
14#include <so_5/disp_binder.hpp>
15#include <so_5/nonempty_name.hpp>
17#include <so_5/disp/mpsc_queue_traits/pub.hpp>
19#include <so_5/disp/reuse/work_thread_activity_tracking.hpp>
20#include <so_5/disp/reuse/work_thread_factory_params.hpp>
35
36
37
38
39
46
47
48
49
50
68 static_cast< activity_tracking_mixin_t & >(a),
69 static_cast< activity_tracking_mixin_t & >(b) );
75 swap( a.m_queue_params, b.m_queue_params );
82 m_queue_params = std::move(p);
88
89
90
91
92
93
94
95
96
97
98
99 template<
typename L >
111 return m_queue_params;
127
128
129
130
131
132
133
134
158
159
160
161
162
171 impl::basic_dispatcher_iface_shptr_t dispatcher )
noexcept
177 empty()
const noexcept {
return !m_dispatcher; }
184
185
186
193 return m_dispatcher->binder( std::move(group_name) );
205 reset()
noexcept { m_dispatcher.reset(); }
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
236 const std::string_view data_sources_name_base,
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
264 const std::string_view data_sources_name_base )
266 return make_dispatcher( env, data_sources_name_base, disp_params_t{} );
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
290 return make_dispatcher( env, std::string_view{} );
Alias for namespace with traits of event queue.
const queue_traits::queue_params_t & queue_params() const
Getter for queue parameters.
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
disp_params_t & set_queue_params(queue_traits::queue_params_t p)
Setter for queue parameters.
disp_params_t()=default
Default constructor.
A handle for active_group dispatcher.
dispatcher_handle_t(impl::basic_dispatcher_iface_shptr_t dispatcher) noexcept
dispatcher_handle_t() noexcept=default
impl::basic_dispatcher_iface_shptr_t m_dispatcher
A reference to actual implementation of a dispatcher.
bool empty() const noexcept
Is this handle empty?
void reset() noexcept
Drop the content of handle.
bool operator!() const noexcept
Does this handle contain a reference to dispatcher?
operator bool() const noexcept
Is this handle empty?
disp_binder_shptr_t binder(nonempty_name_t group_name) const
Get a binder for that dispatcher.
const std::string m_group_name
Name of group for new agents.
void preallocate_resources(agent_t &) override
Allocate resources in dispatcher for new agent.
void unbind(agent_t &) noexcept override
Unbind agent from dispatcher.
void bind(agent_t &agent) noexcept override
Bind agent to dispatcher.
actual_dispatcher_iface_shptr_t m_disp
Dispatcher to be used.
void undo_preallocation(agent_t &) noexcept override
Undo resources allocation.
actual_binder_t(actual_dispatcher_iface_shptr_t disp, nonempty_name_t group_name) noexcept
An actual interface of active group dispatcher.
virtual so_5::event_queue_t * query_thread_for_group(const std::string &group_name) noexcept=0
Get the event_queue for the specified active group.
virtual void release_thread_for_group(const std::string &group_name) noexcept=0
Release the thread for the specified active group.
virtual void allocate_thread_for_group(const std::string &group_name)=0
Create a new thread for a group if it necessary.
The very basic interface of active_group dispatcher.
virtual ~basic_dispatcher_iface_t() noexcept=default
virtual disp_binder_shptr_t binder(nonempty_name_t group_name)=0
static dispatcher_handle_t make(actual_dispatcher_iface_shptr_t disp) noexcept
outliving_reference_t< dispatcher_template_t > m_dispatcher
Dispatcher to work with.
void distribute_value_for_work_thread(const so_5::mbox_t &mbox, const std::string &group_name, const thread_with_refcounter_t &wt)
disp_data_source_t(const std::string_view name_base, outliving_reference_t< dispatcher_template_t > disp)
stats::prefix_t m_base_prefix
Basic prefix for data sources.
void distribute(const so_5::mbox_t &mbox) override
Send appropriate notification about the current value.
void release_thread_for_group(const std::string &group_name) noexcept override
Release the thread for the specified active group.
void allocate_thread_for_group(const std::string &group_name) override
Create a new thread for a group if it necessary.
outliving_reference_t< environment_t > m_env
SObjectizer Environment to work in.
std::mutex m_lock
This object lock.
so_5::event_queue_t * query_thread_for_group(const std::string &group_name) noexcept override
Get the event_queue for the specified active group.
active_group_map_t m_groups
A map of dispatchers for active groups.
const disp_params_t m_params
Parameters for the dispatcher.
dispatcher_template_t(outliving_reference_t< environment_t > env, const std::string_view name_base, disp_params_t params)
~dispatcher_template_t() noexcept override
work_thread_shptr_t search_and_try_remove_group_from_map(const std::string &group_name) noexcept
Helper function for searching and erasing agent's thread from map of active threads.
stats::auto_registered_source_holder_t< disp_data_source_t > m_data_source
Data source for run-time monitoring.
disp_binder_shptr_t binder(nonempty_name_t group_name) override
Container for storing parameters for MPSC queue.
Mixin with thread activity tracking flag.
Mixin that holds optional work thread factory.
Interface for dispatcher binders.
An interface of event queue for agent.
A class for the name which cannot be empty.
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 shutdown_and_wait(T &w)
Just a helper function for consequetive call to shutdown and wait.
void send_thread_activity_stats(const so_5::mbox_t &, const stats::prefix_t &, work_thread::work_thread_no_activity_tracking_t &)
void send_thread_activity_stats(const so_5::mbox_t &mbox, const stats::prefix_t &prefix, work_thread::work_thread_with_activity_tracking_t &wt)
Active groups dispatcher implemetation details.
Active groups dispatcher.
dispatcher_handle_t make_dispatcher(so_5::environment_t &env, const std::string_view data_sources_name_base)
Create an instance of active_group dispatcher.
dispatcher_handle_t make_dispatcher(so_5::environment_t &env)
Create an instance of active_group 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 active_group dispatcher.
Various stuff related to MPSC event queue implementation and tuning.
Implemetation details of dispatcher's working thread.
Reusable components for dispatchers.
All stuff related to run-time monitoring and statistics.
Private part of message limit implementation.
Auxiliary class for the working agent counting.
work_thread_shptr_t m_thread