2
3
6
7
8
9
10
12#include <so_5/disp/thread_pool/pub.hpp>
14#include <so_5/disp/thread_pool/impl/disp.hpp>
16#include <so_5/disp/reuse/make_actual_dispatcher.hpp>
18#include <so_5/ret_code.hpp>
20#include <so_5/disp_binder.hpp>
21#include <so_5/environment.hpp>
39
40
41
42
43
44
72using actual_dispatcher_iface_shptr_t =
79
80
81
82
86 actual_dispatcher_iface_shptr_t
m_disp;
92 actual_dispatcher_iface_shptr_t disp,
94 :
m_disp{ std::move(disp) }
107 agent_t & agent )
noexcept override
114 agent_t & agent )
noexcept override
122 agent_t & agent )
noexcept override
132
133
134
135
136template<
typename Work_Thread >
137class actual_dispatcher_implementation_t
final
141 dispatcher_template_t< Work_Thread >
m_impl;
148 const std::string_view name_base,
164 m_impl.shutdown_then_wait();
171 return std::make_shared< actual_binder_t >(
172 this->shared_from_this(),
181 m_impl.preallocate_resources_for_agent( agent, params );
186 agent_t & agent )
noexcept override
188 m_impl.undo_preallocation_for_agent( agent );
194 return m_impl.query_resources_for_agent( agent );
200 m_impl.unbind_agent( agent );
211 make( actual_dispatcher_iface_shptr_t disp )
noexcept
213 return { std::move( disp )
};
245 const std::string_view data_sources_name_base,
252 using dispatcher_no_activity_tracking_t =
253 impl::actual_dispatcher_implementation_t<
254 impl::work_thread_no_activity_tracking_t<
255 impl::dispatcher_queue_t
259 using dispatcher_with_activity_tracking_t =
260 impl::actual_dispatcher_implementation_t<
261 impl::work_thread_with_activity_tracking_t<
262 impl::dispatcher_queue_t
268 dispatcher_no_activity_tracking_t
,
269 dispatcher_with_activity_tracking_t
>(
271 data_sources_name_base
,
void so_bind_to_dispatcher(event_queue_t &queue) noexcept
Binding agent to the dispatcher.
Parameters for binding agents to thread_pool dispatcher.
Alias for namespace with traits of event queue.
disp_params_t & thread_count(std::size_t count)
Setter for thread count.
const queue_traits::queue_params_t & queue_params() const
Getter for queue parameters.
std::size_t thread_count() const
Getter for thread count.
A handle for thread_pool 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.
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.
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...
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.
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.
Private part of message limit implementation.
outliving_reference_t< T > outliving_mutable(T &r)
Make outliving_reference wrapper for mutable reference.