2
3
6
7
8
9
10
11
15#include <so_5/declspec.hpp>
17#include <so_5/disp_binder.hpp>
19#include <so_5/disp/mpmc_queue_traits/pub.hpp>
21#include <so_5/disp/reuse/work_thread_activity_tracking.hpp>
22#include <so_5/disp/reuse/work_thread_factory_params.hpp>
23#include <so_5/disp/reuse/default_thread_pool_size.hpp>
39
40
41
42
49
50
51
52
73 static_cast< activity_tracking_mixin_t & >(a),
74 static_cast< activity_tracking_mixin_t & >(b) );
80 swap( a.m_thread_count, b.m_thread_count );
81 swap( a.m_queue_params, b.m_queue_params );
88 m_thread_count = count;
96 return m_thread_count;
103 m_queue_params = std::move(p);
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123 template<
typename L >
135 return m_queue_params;
141
142
152
153
154
155
163 m_max_demands_at_once = v;
172 return m_max_demands_at_once;
193
194
195
196
197
198
199
223
224
225
226
235 impl::basic_dispatcher_iface_shptr_t dispatcher )
noexcept
241 empty()
const noexcept {
return !m_dispatcher; }
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
278 return m_dispatcher->binder( params );
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305 template<
typename Setter >
322
323
324
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
376 const std::string_view data_sources_name_base,
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
407 const std::string_view data_sources_name_base,
409 std::size_t thread_count )
411 return make_dispatcher(
413 data_sources_name_base,
414 disp_params_t{}.thread_count( thread_count ) );
418
419
420
421
422
423
424
425
426
427
428
429
430
431
438 std::size_t thread_count )
440 return make_dispatcher( env, std::string_view{}, thread_count );
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
471 return make_dispatcher(
474 default_thread_pool_size() );
The base class for the object with a reference counting.
Container for storing parameters for MPMC queue.
Parameters for binding agents to nef_thread_pool dispatcher.
bind_params_t & max_demands_at_once(std::size_t v)
Set maximum count of demands to be processed at once.
std::size_t m_max_demands_at_once
Maximum count of demands to be processed at once.
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.
const queue_traits::queue_params_t & queue_params() const
Getter for queue parameters.
std::size_t m_thread_count
Count of working threads.
disp_params_t & tune_queue_params(L tunner)
Tuner for queue parameters.
disp_params_t & set_queue_params(queue_traits::queue_params_t p)
Setter for queue parameters.
queue_traits::queue_params_t m_queue_params
Queue parameters.
disp_params_t & thread_count(std::size_t count)
Setter for thread count.
friend void swap(disp_params_t &a, disp_params_t &b) noexcept
std::size_t thread_count() const
Getter for thread count.
disp_params_t()=default
Default constructor.
A handle for nef_thread_pool dispatcher.
impl::basic_dispatcher_iface_shptr_t m_dispatcher
A reference to actual implementation of a dispatcher.
bool empty() const noexcept
Is this handle empty?
disp_binder_shptr_t binder(bind_params_t params) const
Get a binder for that dispatcher.
dispatcher_handle_t() noexcept=default
dispatcher_handle_t(impl::basic_dispatcher_iface_shptr_t dispatcher) noexcept
void bind(agent_t &agent) noexcept override
Bind agent to dispatcher.
actual_binder_t(actual_dispatcher_iface_shptr_t disp, bind_params_t params) noexcept
const bind_params_t m_params
Binding parameters.
actual_dispatcher_iface_shptr_t m_disp
Dispatcher to be used.
void preallocate_resources(agent_t &agent) override
Allocate resources in dispatcher for new agent.
void undo_preallocation(agent_t &agent) noexcept override
Undo resources allocation.
void unbind(agent_t &agent) noexcept override
Unbind agent from dispatcher.
An actual interface of nef-thread-pool dispatcher.
virtual event_queue_t * query_resources_for_agent(agent_t &agent) noexcept=0
Get resources allocated for an agent.
virtual void undo_preallocation_for_agent(agent_t &agent) noexcept=0
Undo preallocation of resources for a new agent.
virtual void unbind_agent(agent_t &agent) noexcept=0
Unbind agent from the dispatcher.
virtual void preallocate_resources_for_agent(agent_t &agent, const bind_params_t ¶ms)=0
Preallocate all necessary resources for a new agent.
~actual_dispatcher_implementation_t() noexcept override
disp_binder_shptr_t binder(bind_params_t params) override
void undo_preallocation_for_agent(agent_t &agent) noexcept override
Undo preallocation of resources for a new agent.
event_queue_t * query_resources_for_agent(agent_t &agent) noexcept override
Get resources allocated for an agent.
void preallocate_resources_for_agent(agent_t &agent, const bind_params_t ¶ms) override
Preallocate all necessary resources for a new agent.
actual_dispatcher_implementation_t(outliving_reference_t< environment_t > env, const std::string_view name_base, disp_params_t params)
dispatcher_template_t< Work_Thread > m_impl
Real dispatcher.
void unbind_agent(agent_t &agent) noexcept override
Unbind agent from the dispatcher.
void schedule_on_disp_queue() noexcept override
Perform scheduling of processing of this event queue.
dispatcher_queue_t & m_disp_queue
Dispatcher queue with that the agent queue has to be used.
agent_queue_with_preallocated_finish_demand_t * intrusive_queue_giveout_next() noexcept
Give away a pointer to the next agent_queue.
std::unique_ptr< base_type_t::demand_t > m_finish_demand
A preallocated demand for evt_finish.
void push_evt_finish(execution_demand_t demand) noexcept override
agent_queue_with_preallocated_finish_demand_t * m_intrusive_queue_next
The next item in intrusive queue of agent_queues.
agent_queue_with_preallocated_finish_demand_t(outliving_reference_t< dispatcher_queue_t > disp_queue, const bind_params_t ¶ms)
Initializing constructor.
void intrusive_queue_set_next(agent_queue_with_preallocated_finish_demand_t *next) noexcept
Set a pointer to the next agent_queue.
The very basic interface of thread_pool dispatcher.
virtual disp_binder_shptr_t binder(bind_params_t params)=0
virtual ~basic_dispatcher_iface_t() noexcept=default
static dispatcher_handle_t make(actual_dispatcher_iface_shptr_t disp) noexcept
Multi-producer/Multi-consumer queue of pointers to event queues.
Mixin with thread activity tracking flag.
Mixin that holds optional work thread factory.
std::vector< std::unique_ptr< Work_Thread > > m_threads
Pool of work threads.
void wait_for_emptyness() noexcept
Wait while queue becomes empty.
Interface for dispatcher binders.
An interface of event queue for agent.
Template class for smart reference wrapper on the atomic_refcounted_t.
Helper class for indication of long-lived reference via its type.
Various stuff related to MPMC event queue implementation and tuning.
void adjust_thread_count(disp_params_t ¶ms)
Sets the thread count to default value if used do not specify actual thread count.
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 nef_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 nef_thread_pool dispatcher.
dispatcher_handle_t make_dispatcher(environment_t &env, std::size_t thread_count)
Create an instance of nef_thread_pool dispatcher.
dispatcher_handle_t make_dispatcher(environment_t &env)
Create an instance of nef_thread_pool dispatcher with the default count of working threads.
Reusable components for dispatchers.
Reusable implementation of some thread pool dispatcher functionality which can be used in other threa...
Internal implementation details of thread pool dispatcher.
Private part of message limit implementation.
Adaptation of common implementation of thread-pool-like dispatcher to the specific of this thread-poo...
static bool is_individual_fifo(const bind_params_t &) noexcept
static constexpr std::string_view dispatcher_type_name() noexcept
static void wait_for_queue_emptyness(agent_queue_with_preallocated_finish_demand_t &queue) noexcept
A description of event execution demand.