SObjectizer  5.8
Loading...
Searching...
No Matches
so_5::disp::reuse Namespace Reference

Reusable components for dispatchers. More...

Namespaces

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

Classes

class  queue_of_queues_t
 Multi-producer/Multi-consumer queue of pointers to event queues. 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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
std::size_t default_thread_pool_size ()
 A helper function for detecting default thread count for thread pool.
 

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 )
nodiscard

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

Definition at line 69 of file actual_work_thread_factory_to_use.hpp.

◆ 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 )
nodiscardnoexcept

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.

Definition at line 43 of file actual_work_thread_factory_to_use.hpp.

◆ default_thread_pool_size()

std::size_t so_5::disp::reuse::default_thread_pool_size ( )
inlinenodiscard

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.8.0

Definition at line 31 of file default_thread_pool_size.hpp.

◆ 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(
const std::string_view data_source_base_name,
Disp_Params_Type disp_params,
Args && ...additional_args );
Helper class for indication of long-lived reference via its type.
Definition outliving.hpp:98
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

Definition at line 97 of file make_actual_dispatcher.hpp.

◆ 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.

Definition at line 36 of file data_source_prefix_helpers.hpp.

◆ 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.

Definition at line 66 of file data_source_prefix_helpers.hpp.

◆ 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

Definition at line 42 of file make_actual_dispatcher.hpp.