SObjectizer  5.5
Namespaces | Classes | Typedefs | Functions
so_5::disp::mpmc_queue_traits Namespace Reference

Various stuff related to MPMC event queue implementation and tuning. More...

Namespaces

 combined_lock
 Implementation of combined lock for MPMC event queue.
 
 simple_lock
 Implementation of simple lock for MPMC event queue.
 

Classes

class  condition_t
 An interface for somethine like condition variable for waiting on MPMC queue lock. More...
 
class  lock_t
 An interface for lock for MPMC queue. More...
 
class  queue_params_t
 Container for storing parameters for MPMC queue. More...
 

Typedefs

using condition_unique_ptr_t = std::unique_ptr< condition_t >
 Alias of unique_ptr for condition. More...
 
using lock_unique_ptr_t = std::unique_ptr< lock_t >
 An alias for unique_ptr for lock. More...
 
using lock_factory_t = std::function< lock_unique_ptr_t() >
 Type of lock factory. More...
 

Functions

SO_5_FUNC lock_factory_t combined_lock_factory ( std::chrono::high_resolution_clock::duration waiting_time)
 Factory for creation of combined queue lock with the specified waiting time. More...
 
SO_5_FUNC lock_factory_t simple_lock_factory ()
 Factory for creation of very simple implementation based on usage of mutex and condition_variable only. More...
 
std::chrono::high_resolution_clock::duration default_combined_lock_waiting_time ()
 Default timeout used by combined_lock for waiting on spinlock before switching to mutex-based locking scheme. More...
 
lock_factory_t combined_lock_factory ()
 Factory for creation of combined queue lock with default waiting time. More...
 

Detailed Description

Various stuff related to MPMC event queue implementation and tuning.

Since
v.5.5.11

Typedef Documentation

◆ condition_unique_ptr_t

Alias of unique_ptr for condition.

Since
v.5.5.11

◆ lock_factory_t

Type of lock factory.

Since
v.5.5.11

◆ lock_unique_ptr_t

using so_5::disp::mpmc_queue_traits::lock_unique_ptr_t = typedef std::unique_ptr< lock_t >

An alias for unique_ptr for lock.

Since
v.5.5.11

Function Documentation

◆ combined_lock_factory() [1/2]

lock_factory_t so_5::disp::mpmc_queue_traits::combined_lock_factory ( )
inline

Factory for creation of combined queue lock with default waiting time.

Usage example:
so_5::launch( []( so_5::environment_t & env ) { ... },
[]( so_5::environment_params_t & params ) {
// Add another thread_pool dispatcher with combined_lock for
// event queue protection.
using namespace so_5::disp::thread_pool;
params.add_named_dispatcher(
"helpers_disp",
[]( queue_traits::queue_params_t & queue_params ) {
} ) ) );
} );
Since
v.5.5.11

◆ combined_lock_factory() [2/2]

SO_5_FUNC lock_factory_t so_5::disp::mpmc_queue_traits::combined_lock_factory ( std::chrono::high_resolution_clock::duration  waiting_time)

Factory for creation of combined queue lock with the specified waiting time.

Usage example:
so_5::launch( []( so_5::environment_t & env ) { ... },
[]( so_5::environment_params_t & params ) {
// Add another thread_pool dispatcher with combined_lock for
// event queue protection.
using namespace so_5::disp::thread_pool;
params.add_named_dispatcher(
"helpers_disp",
[]( queue_traits::queue_params_t & queue_params ) {
// Switching to mutex will be after waiting for 500us.
std::chrono::microseconds(500) ) );
} ) ) );
} );
Since
v.5.5.11
Parameters
waiting_timeMax waiting time for waiting on spinlock before switching to mutex.

◆ default_combined_lock_waiting_time()

std::chrono::high_resolution_clock::duration so_5::disp::mpmc_queue_traits::default_combined_lock_waiting_time ( )
inline

Default timeout used by combined_lock for waiting on spinlock before switching to mutex-based locking scheme.

Since
v.5.5.11

◆ simple_lock_factory()

SO_5_FUNC lock_factory_t so_5::disp::mpmc_queue_traits::simple_lock_factory ( )

Factory for creation of very simple implementation based on usage of mutex and condition_variable only.

Usage example:
so_5::launch( []( so_5::environment_t & env ) { ... },
[]( so_5::environment_params_t & params ) {
// Add another thread_pool dispatcher with simple_lock for
// event queue protection.
using namespace so_5::disp::thread_pool;
params.add_named_dispatcher(
"helpers_disp",
[]( queue_traits::queue_params_t & queue_params ) {
} ) ) );
} );
Since
v.5.5.11