SObjectizer  5.7
Namespaces | Classes | Enumerations | Functions
so_5::disp::adv_thread_pool Namespace Reference

Advanced thread pool dispatcher. More...

Namespaces

 anonymous_namespace{pub.cpp}
 
 impl
 Internal implementation details of advanced thread pool dispatcher.
 

Classes

class  bind_params_t
 Parameters for binding agents to adv_thread_pool dispatcher. More...
 
class  disp_params_t
 Alias for namespace with traits of event queue. More...
 
class  dispatcher_handle_t
 A handle for adv_thread_pool dispatcher. More...
 

Enumerations

enum  fifo_t { fifo_t::cooperation, fifo_t::individual }
 Type of FIFO mechanism for agent's demands. More...
 

Functions

SO_5_FUNC dispatcher_handle_t make_dispatcher ( environment_t &env, const std::string_view data_sources_name_base, disp_params_t disp_params)
 Create an instance of adv_thread_pool dispatcher. More...
 
std::size_t default_thread_pool_size ()
 A helper function for detecting default thread count for thread pool. More...
 
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 adv_thread_pool dispatcher. More...
 
dispatcher_handle_t make_dispatcher (environment_t &env, std::size_t thread_count)
 Create an instance of adv_thread_pool dispatcher. More...
 
dispatcher_handle_t make_dispatcher (environment_t &env)
 Create an instance of adv_thread_pool dispatcher with the default count of work threads. More...
 

Detailed Description

Advanced thread pool dispatcher.

Enumeration Type Documentation

◆ fifo_t

Type of FIFO mechanism for agent's demands.

Since
v.5.4.0
Enumerator
cooperation 

A FIFO for demands for all agents from the same cooperation.

It means that agents from the same cooperation for which this FIFO mechanism is used will be worked on the same thread.

individual 

A FIFO for demands only for one agent.

It means that FIFO is only supported for the concrete agent. If several agents from a cooperation have this FIFO type they will process demands independently and on different threads.

Function Documentation

◆ default_thread_pool_size()

std::size_t so_5::disp::adv_thread_pool::default_thread_pool_size ( )
inline

A helper function for detecting default thread count for thread pool.

Returns value of std::thread::hardware_concurrency() or 2 if hardware_concurrency() returns 0.

Since
v.5.4.0

◆ make_dispatcher() [1/4]

SO_5_FUNC dispatcher_handle_t so_5::disp::adv_thread_pool::make_dispatcher ( environment_t env,
const std::string_view  data_sources_name_base,
disp_params_t  disp_params 
)

Create an instance of adv_thread_pool dispatcher.

Usage sample
auto disp = make_dispatcher(
env,
"db_workers_pool",
.thread_count( 16 )
} ) );
auto coop = env.make_coop(
// The main dispatcher for that coop will be
// this instance of adv_thread_pool dispatcher.
disp.binder() );
Since
v.5.6.0
Parameters
envSObjectizer Environment to work in.
data_sources_name_baseValue for creating names of data sources for run-time monitoring.
disp_paramsParameters for the dispatcher.
Examples:
so_5/hardwork_imit/main.cpp.

◆ make_dispatcher() [2/4]

dispatcher_handle_t so_5::disp::adv_thread_pool::make_dispatcher ( environment_t env,
const std::string_view  data_sources_name_base,
std::size_t  thread_count 
)
inline

Create an instance of adv_thread_pool dispatcher.

Usage sample
env,
"req_processors",
16 );
auto coop = env.make_coop(
// The main dispatcher for that coop will be
// this instance of adv_thread_pool dispatcher.
disp.binder() );
Since
v.5.6.0
Parameters
envSObjectizer Environment to work in.
data_sources_name_baseValue for creating names of data sources for run-time monitoring.
thread_countCount of working threads.

◆ make_dispatcher() [3/4]

dispatcher_handle_t so_5::disp::adv_thread_pool::make_dispatcher ( environment_t env,
std::size_t  thread_count 
)
inline

Create an instance of adv_thread_pool dispatcher.

Usage sample
auto coop = env.make_coop(
// The main dispatcher for that coop will be
// this instance of adv_thread_pool dispatcher.
disp.binder() );
Since
v.5.6.0
Parameters
envSObjectizer Environment to work in.
thread_countCount of working threads.

◆ make_dispatcher() [4/4]

dispatcher_handle_t so_5::disp::adv_thread_pool::make_dispatcher ( environment_t env)
inline

Create an instance of adv_thread_pool dispatcher with the default count of work threads.

Count of work threads will be detected by default_thread_pool_size() function.

Usage sample
auto coop = env.make_coop(
// The main dispatcher for that coop will be
// this instance of adv_thread_pool dispatcher.
disp.binder() );
Since
v.5.6.0
Parameters
envSObjectizer Environment to work in.