SObjectizer  5.7
Namespaces | Classes | Functions
so_5::disp::reuse Namespace Reference

Reusable components for dispatchers. More...

Namespaces

 locks
 Implementation of various types of locks to be used inside dispatchers.
 
 thread_pool_stats
 Helper tools for implementation of run-time monitoring for thread-pool-like dispatchers.
 
 work_thread
 Implemetation details of dispatcher's working thread.
 

Classes

class  mpmc_ptr_queue_t
 Multi-producer/Multi-consumer queue of pointers. More...
 
class  work_thread_activity_tracking_flag_mixin_t
 Mixin with thread activity tracking flag. More...
 
class  work_thread_factory_mixin_t
 Mixin that holds optional work thread factory. More...
 

Functions

template<typename Params >
abstract_work_thread_factory_shptr_t actual_work_thread_factory_to_use (const work_thread_factory_mixin_t< Params > &params, const environment_t &env) noexcept
 Helper to detect actual work thread factory to be used. More...
 
template<typename Params >
work_thread_holder_t acquire_work_thread (const work_thread_factory_mixin_t< Params > &params, environment_t &env)
 Helper function for acquiring a new worker thread from an appropriate work thread factory. More...
 
so_5::stats::prefix_t make_disp_prefix (const std::string_view disp_type, const std::string_view data_sources_name_base, const void *disp_this_pointer)
 Create basic prefix for dispatcher data source names. More...
 
so_5::stats::prefix_t make_disp_working_thread_prefix (const so_5::stats::prefix_t &disp_prefix, std::size_t thread_number)
 Create prefix for dispatcher's working thread data source. More...
 
template<typename Disp_Params_Type >
void modify_disp_params (so_5::environment_t &env, Disp_Params_Type &params)
 Helper functions to adjust some dispatcher parameters with respect to settings from environment. More...
 
template<typename Disp_Iface_Type , typename Disp_No_Tracking , typename Disp_With_Tracking , typename Disp_Params_Type , typename... Args>
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 flag. More...
 

Detailed Description

Reusable components for dispatchers.

This namespace contains classes and functions which can be reused by various types of dispatchers.

Function Documentation

◆ acquire_work_thread()

template<typename Params >
work_thread_holder_t so_5::disp::reuse::acquire_work_thread ( const work_thread_factory_mixin_t< Params > &  params,
environment_t env 
)

Helper function for acquiring a new worker thread from an appropriate work thread factory.

If params defines a factory then the factory from params is used for acquiring new work thread. Otherwise the factory from env is used.

Since
v.5.7.3

◆ actual_work_thread_factory_to_use()

template<typename Params >
abstract_work_thread_factory_shptr_t so_5::disp::reuse::actual_work_thread_factory_to_use ( const work_thread_factory_mixin_t< Params > &  params,
const environment_t env 
)
noexcept

Helper to detect actual work thread factory to be used.

If params defines a factory then the factory from params is returned. Otherwise, the factory from env is returned.

◆ make_actual_dispatcher()

template<typename Disp_Iface_Type , typename Disp_No_Tracking , typename Disp_With_Tracking , typename Disp_Params_Type , typename... Args>
std::unique_ptr< Disp_Iface_Type > so_5::disp::reuse::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 flag.

Note
Calls modify_disp_params() before creation of dispatcher instance.
Attention
Dispatcher constructor should have the following format:
Dispatcher(
outliving_reference_t<environment_t> env,
const std::string_view data_source_base_name,
Disp_Params_Type disp_params,
Args && ...additional_args );
Template Parameters
Disp_Iface_Typea type of interface for actual dispatcher. This type is expected to be a base class for Disp_No_Tracking and Disp_With_Tracking types.
Disp_No_Trackinga type of dispatcher for case when thread activity tracking is not used.
Disp_With_Trackinga type of dispatcher for case when thread activity tracking is used.
Disp_Params_Typea type of dispatcher-specific parameters.
Argstypes of additional arguments for dispatcher's constructor.
Since
v.5.6.0

◆ make_disp_prefix()

so_5::stats::prefix_t so_5::disp::reuse::make_disp_prefix ( const std::string_view  disp_type,
const std::string_view  data_sources_name_base,
const void *  disp_this_pointer 
)
inline

Create basic prefix for dispatcher data source names.

Since
v.5.5.4
Parameters
disp_typeTextual marker of dispatcher type (like ot, ao, ag, tp, atp, ...).
data_sources_name_baseUser-supplied optional base for name. Can be empty.
disp_this_pointerPointer to dispatcher instance. Will be used if data_sources_name_base is empty.

◆ make_disp_working_thread_prefix()

so_5::stats::prefix_t so_5::disp::reuse::make_disp_working_thread_prefix ( const so_5::stats::prefix_t disp_prefix,
std::size_t  thread_number 
)
inline

Create prefix for dispatcher's working thread data source.

Since
v.5.5.4
Parameters
disp_prefixPrefix for the dispatcher.
thread_numberThread ordinal number.

◆ modify_disp_params()

template<typename Disp_Params_Type >
void so_5::disp::reuse::modify_disp_params ( so_5::environment_t env,
Disp_Params_Type &  params 
)

Helper functions to adjust some dispatcher parameters with respect to settings from environment.

If dispatcher params doesn't have lock-factory specified the lock-factory will be inherited from environment.

Template Parameters
Disp_Params_Typetype of struct/class with dispatcher-related parameters. This type should have queue_params() method.
Since
v.5.6.0