2
3
6
7
8
9
10
14#include <so_5/declspec.hpp>
16#include <so_5/disp_binder.hpp>
18#include <so_5/disp/mpmc_queue_traits/pub.hpp>
20#include <so_5/disp/reuse/work_thread_activity_tracking.hpp>
21#include <so_5/disp/reuse/work_thread_factory_params.hpp>
22#include <so_5/disp/reuse/default_thread_pool_size.hpp>
38
39
40
41
48
49
50
51
72 static_cast< activity_tracking_mixin_t & >(a),
73 static_cast< activity_tracking_mixin_t & >(b) );
79 swap( a.m_thread_count, b.m_thread_count );
80 swap( a.m_queue_params, b.m_queue_params );
87 m_thread_count = count;
95 return m_thread_count;
102 m_queue_params = std::move(p);
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122 template<
typename L >
134 return m_queue_params;
140
141
151
152
153
154
159
160
161
162
163
164
165
166
170
171
172
173
181
182
183
184
208 m_max_demands_at_once = v;
217 return m_max_demands_at_once;
241
242
243
244
245
246
247
271
272
273
274
283 impl::basic_dispatcher_iface_shptr_t dispatcher )
noexcept
289 empty()
const noexcept {
return !m_dispatcher; }
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
326 return m_dispatcher->binder( params );
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353 template<
typename Setter >
370
371
372
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
424 const std::string_view data_sources_name_base,
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
455 const std::string_view data_sources_name_base,
457 std::size_t thread_count )
459 return make_dispatcher(
461 data_sources_name_base,
462 disp_params_t{}.thread_count( thread_count ) );
466
467
468
469
470
471
472
473
474
475
476
477
478
479
486 std::size_t thread_count )
488 return make_dispatcher( env, std::string_view{}, thread_count );
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
519 return make_dispatcher(
522 default_thread_pool_size() );
Container for storing parameters for MPMC queue.
Mixin with thread activity tracking flag.
Mixin that holds optional work thread factory.
Parameters for binding agents to thread_pool dispatcher.
std::size_t m_max_demands_at_once
Maximum count of demands to be processed at once.
bind_params_t & max_demands_at_once(std::size_t v)
Set maximum count of demands to be processed at once.
fifo_t query_fifo() const
Get FIFO type.
bind_params_t & fifo(fifo_t v)
Set FIFO type.
std::size_t query_max_demands_at_once() const
Get maximum count of demands to do processed at once.
Alias for namespace with traits of event queue.
queue_traits::queue_params_t m_queue_params
Queue parameters.
disp_params_t & thread_count(std::size_t count)
Setter for thread count.
disp_params_t()=default
Default constructor.
disp_params_t & tune_queue_params(L tunner)
Tuner for queue parameters.
const queue_traits::queue_params_t & queue_params() const
Getter for queue parameters.
disp_params_t & set_queue_params(queue_traits::queue_params_t p)
Setter for queue parameters.
friend void swap(disp_params_t &a, disp_params_t &b) noexcept
std::size_t m_thread_count
Count of working threads.
std::size_t thread_count() const
Getter for thread count.
A handle for thread_pool dispatcher.
bool empty() const noexcept
Is this handle empty?
impl::basic_dispatcher_iface_shptr_t m_dispatcher
A reference to actual implementation of a dispatcher.
dispatcher_handle_t() noexcept=default
disp_binder_shptr_t binder(bind_params_t params) const
Get a binder for that dispatcher.
dispatcher_handle_t(impl::basic_dispatcher_iface_shptr_t dispatcher) noexcept
void unbind(agent_t &agent) noexcept override
Unbind agent from dispatcher.
void undo_preallocation(agent_t &agent) noexcept override
Undo resources allocation.
void bind(agent_t &agent) noexcept override
Bind agent to dispatcher.
void preallocate_resources(agent_t &agent) override
Allocate resources in dispatcher for new agent.
const bind_params_t m_params
Binding parameters.
actual_binder_t(actual_dispatcher_iface_shptr_t disp, bind_params_t params) noexcept
actual_dispatcher_iface_shptr_t m_disp
Dispatcher to be used.
An actual interface of thread-pool dispatcher.
virtual void undo_preallocation_for_agent(agent_t &agent) noexcept=0
Undo preallocation of resources for a new agent.
virtual event_queue_t * query_resources_for_agent(agent_t &agent) noexcept=0
Get resources allocated for an agent.
virtual void preallocate_resources_for_agent(agent_t &agent, const bind_params_t ¶ms)=0
Preallocate all necessary resources for a new agent.
virtual void unbind_agent(agent_t &agent) noexcept=0
Unbind agent from the dispatcher.
void undo_preallocation_for_agent(agent_t &agent) noexcept override
Undo preallocation of resources for a new agent.
dispatcher_template_t< Work_Thread > m_impl
Real dispatcher.
disp_binder_shptr_t binder(bind_params_t params) override
~actual_dispatcher_implementation_t() noexcept override
void preallocate_resources_for_agent(agent_t &agent, const bind_params_t ¶ms) override
Preallocate all necessary resources for a new agent.
void unbind_agent(agent_t &agent) noexcept override
Unbind agent from the dispatcher.
actual_dispatcher_implementation_t(outliving_reference_t< environment_t > env, const std::string_view name_base, disp_params_t params)
event_queue_t * query_resources_for_agent(agent_t &agent) noexcept override
Get resources allocated for an agent.
The very basic interface of thread_pool dispatcher.
virtual ~basic_dispatcher_iface_t() noexcept=default
virtual disp_binder_shptr_t binder(bind_params_t params)=0
static dispatcher_handle_t make(actual_dispatcher_iface_shptr_t disp) noexcept
Interface for dispatcher binders.
An interface of event queue for agent.
Helper class for indication of long-lived reference via its type.
Various stuff related to MPMC event queue implementation and tuning.
Reusable components for dispatchers.
void adjust_thread_count(disp_params_t ¶ms)
Sets the thread count to default value if used do not specify actual thread count.
Internal implementation details of thread pool dispatcher.
fifo_t
Type of FIFO mechanism for agent's demands.
@ cooperation
A FIFO for demands for all agents from the same cooperation.
@ individual
A FIFO for demands only for one agent.
dispatcher_handle_t make_dispatcher(environment_t &env, std::size_t thread_count)
Create an instance of thread_pool 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 thread_pool dispatcher.
dispatcher_handle_t make_dispatcher(environment_t &env, const std::string_view data_sources_name_base, std::size_t thread_count)
Create an instance of thread_pool dispatcher.
dispatcher_handle_t make_dispatcher(environment_t &env)
Create an instance of thread_pool dispatcher with the default count of working threads.
Private part of message limit implementation.