2
3
6
7
8
9
10
11
13#include <so_5/disp/nef_thread_pool/pub.hpp>
15#include <so_5/disp/thread_pool/impl/work_thread_template.hpp>
16#include <so_5/disp/thread_pool/impl/basic_event_queue.hpp>
18#include <so_5/disp/reuse/make_actual_dispatcher.hpp>
20#include <so_5/ret_code.hpp>
22#include <so_5/disp_binder.hpp>
23#include <so_5/environment.hpp>
40class agent_queue_with_preallocated_finish_demand_t;
46 agent_queue_with_preallocated_finish_demand_t >;
52
53
54
55
56
57
58
59
60
61
62
63class agent_queue_with_preallocated_finish_demand_t
final
85
86
87
88
100
101
102
103
104
105
106
107
109 agent_queue_with_preallocated_finish_demand_t *
118
119
120
121
122
123
124
125
128 agent_queue_with_preallocated_finish_demand_t * next )
noexcept
146
147
148
152
153
154
155
156
157
158
166
167
168
169
170
174 static constexpr std::string_view
190 agent_queue_with_preallocated_finish_demand_t & queue )
noexcept
200
201
202
203
204
205
206
207template<
typename Work_Thread >
208using dispatcher_template_t =
219
220
221
222
223
224
237 agent_t & agent )
noexcept = 0;
252using actual_dispatcher_iface_shptr_t =
259
260
261
262
272 actual_dispatcher_iface_shptr_t disp,
274 :
m_disp{ std::move(disp) }
287 agent_t & agent )
noexcept override
294 agent_t & agent )
noexcept override
302 agent_t & agent )
noexcept override
312
313
314
315
316template<
typename Work_Thread >
317class actual_dispatcher_implementation_t
final
321 dispatcher_template_t< Work_Thread >
m_impl;
328 const std::string_view name_base,
344 m_impl.shutdown_then_wait();
351 return std::make_shared< actual_binder_t >(
352 this->shared_from_this(),
361 m_impl.preallocate_resources_for_agent( agent, params );
366 agent_t & agent )
noexcept override
368 m_impl.undo_preallocation_for_agent( agent );
374 return m_impl.query_resources_for_agent( agent );
380 m_impl.unbind_agent( agent );
391 make( actual_dispatcher_iface_shptr_t disp )
noexcept
393 return { std::move( disp )
};
425 const std::string_view data_sources_name_base,
432 using dispatcher_no_activity_tracking_t =
433 impl::actual_dispatcher_implementation_t<
434 impl::work_thread_no_activity_tracking_t<
435 impl::dispatcher_queue_t
439 using dispatcher_with_activity_tracking_t =
440 impl::actual_dispatcher_implementation_t<
441 impl::work_thread_with_activity_tracking_t<
442 impl::dispatcher_queue_t
448 dispatcher_no_activity_tracking_t
,
449 dispatcher_with_activity_tracking_t
>(
451 data_sources_name_base
,
void so_bind_to_dispatcher(event_queue_t &queue) noexcept
Binding agent to the dispatcher.
The base class for the object with a reference counting.
Parameters for binding agents to nef_thread_pool dispatcher.
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.
disp_params_t & thread_count(std::size_t count)
Setter for thread count.
std::size_t thread_count() const
Getter for thread count.
A handle for nef_thread_pool dispatcher.
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.
static dispatcher_handle_t make(actual_dispatcher_iface_shptr_t disp) noexcept
Multi-producer/Multi-consumer queue of pointers to event queues.
void schedule(T *queue) noexcept
Schedule execution of demands from the queue.
basic_event_queue_t(std::size_t max_demands_at_once)
void push_preallocated(std::unique_ptr< demand_t > tail_demand) noexcept
Helper method that implements pushing of a new preallocated demand to the queue.
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.
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.
Reusable components for dispatchers.
std::size_t default_thread_pool_size()
A helper function for detecting default thread count for thread pool.
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...
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.
outliving_reference_t< T > outliving_mutable(T &r)
Make outliving_reference wrapper for mutable reference.
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
Actual demand in event queue.
A description of event execution demand.