MySQL 9.1.0
Source Code Documentation
temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector > Class Template Reference

Lock-free pool which consists of POOL_SIZE Lock_free_type elements. More...

#include <lock_free_pool.h>

Public Types

using Type = typename Lock_free_type< T, ALIGNMENT, TypeSelector >::Type
 

Public Member Functions

 Lock_free_pool ()
 Default constructor. More...
 
 Lock_free_pool (Lock_free_pool::Type default_value)
 Constructor. More...
 
 Lock_free_pool (const Lock_free_pool &)=delete
 Copy-constructor and copy-assignment operator are disabled. More...
 
Lock_free_pooloperator= (const Lock_free_pool &)=delete
 
 Lock_free_pool (Lock_free_pool &&)=delete
 Ditto for move-constructor and move-assignment operator. More...
 
Lock_free_pooloperator= (Lock_free_pool &&)=delete
 
void store (size_t idx, Lock_free_pool::Type value, std::memory_order order=std::memory_order_seq_cst)
 Atomically replaces current value in an array at given index. More...
 
Lock_free_pool::Type load (size_t idx, std::memory_order order=std::memory_order_seq_cst) const
 Atomically loads and returns the current value from an array at given index. More...
 
bool compare_exchange_strong (size_t idx, Lock_free_pool::Type &expected, Lock_free_pool::Type desired, std::memory_order order=std::memory_order_seq_cst)
 Atomically compares the object representation of an array element at given index with the expected, and if those are bitwise-equal, replaces the former with desired. More...
 
constexpr size_t size () const
 Returns the number of elements this pool contains. More...
 

Private Attributes

std::array< Lock_free_type< T, ALIGNMENT, TypeSelector >, POOL_SIZE > m_lock_free
 

Detailed Description

template<typename T, size_t POOL_SIZE, Alignment ALIGNMENT = Alignment::NATURAL, template< typename, typename=void > class TypeSelector = Lock_free_type_selector>
class temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >

Lock-free pool which consists of POOL_SIZE Lock_free_type elements.

It has all the guarantees and properties of Lock_free_type and its consisting pieces so for more details please consult the documentation of those. E.g. user code can opt-in for different alignment-requirements and/or lock-free type selection algorithms. This type is envisioned to be used as a building block for higher-abstraction (lock-free) ADTs.

Member Typedef Documentation

◆ Type

template<typename T , size_t POOL_SIZE, Alignment ALIGNMENT = Alignment::NATURAL, template< typename, typename=void > class TypeSelector = Lock_free_type_selector>
using temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::Type = typename Lock_free_type<T, ALIGNMENT, TypeSelector>::Type

Constructor & Destructor Documentation

◆ Lock_free_pool() [1/4]

template<typename T , size_t POOL_SIZE, Alignment ALIGNMENT = Alignment::NATURAL, template< typename, typename=void > class TypeSelector = Lock_free_type_selector>
temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::Lock_free_pool ( )
inline

Default constructor.

Uses value-initialization to initialize underlying T's.

◆ Lock_free_pool() [2/4]

template<typename T , size_t POOL_SIZE, Alignment ALIGNMENT = Alignment::NATURAL, template< typename, typename=void > class TypeSelector = Lock_free_type_selector>
temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::Lock_free_pool ( Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::Type  default_value)
inline

Constructor.

Uses explicit value to initialize underlying T's.

◆ Lock_free_pool() [3/4]

template<typename T , size_t POOL_SIZE, Alignment ALIGNMENT = Alignment::NATURAL, template< typename, typename=void > class TypeSelector = Lock_free_type_selector>
temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::Lock_free_pool ( const Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector > &  )
delete

Copy-constructor and copy-assignment operator are disabled.

◆ Lock_free_pool() [4/4]

template<typename T , size_t POOL_SIZE, Alignment ALIGNMENT = Alignment::NATURAL, template< typename, typename=void > class TypeSelector = Lock_free_type_selector>
temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::Lock_free_pool ( Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector > &&  )
delete

Ditto for move-constructor and move-assignment operator.

Member Function Documentation

◆ compare_exchange_strong()

template<typename T , size_t POOL_SIZE, Alignment ALIGNMENT = Alignment::NATURAL, template< typename, typename=void > class TypeSelector = Lock_free_type_selector>
bool temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::compare_exchange_strong ( size_t  idx,
Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::Type expected,
Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::Type  desired,
std::memory_order  order = std::memory_order_seq_cst 
)
inline

Atomically compares the object representation of an array element at given index with the expected, and if those are bitwise-equal, replaces the former with desired.

[in] idx Index of an element whose value is to be compared against. [in] expected Value expected to be found in the atomic object. Gets stored with the actual value of *this if the comparison fails. [in] desired Value to store in the atomic object if it is as expected. [in] order Memory order constraints to enforce.

Returns
True if the underlying atomic value was successfully changed, false otherwise.

◆ load()

template<typename T , size_t POOL_SIZE, Alignment ALIGNMENT = Alignment::NATURAL, template< typename, typename=void > class TypeSelector = Lock_free_type_selector>
Lock_free_pool::Type temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::load ( size_t  idx,
std::memory_order  order = std::memory_order_seq_cst 
) const
inline

Atomically loads and returns the current value from an array at given index.

[in] idx Index of an element whose value is to be returned. [in] order Memory order constraints to enforce.

Returns
Returns the current value from given index.

◆ operator=() [1/2]

template<typename T , size_t POOL_SIZE, Alignment ALIGNMENT = Alignment::NATURAL, template< typename, typename=void > class TypeSelector = Lock_free_type_selector>
Lock_free_pool & temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::operator= ( const Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector > &  )
delete

◆ operator=() [2/2]

template<typename T , size_t POOL_SIZE, Alignment ALIGNMENT = Alignment::NATURAL, template< typename, typename=void > class TypeSelector = Lock_free_type_selector>
Lock_free_pool & temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::operator= ( Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector > &&  )
delete

◆ size()

template<typename T , size_t POOL_SIZE, Alignment ALIGNMENT = Alignment::NATURAL, template< typename, typename=void > class TypeSelector = Lock_free_type_selector>
constexpr size_t temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::size ( ) const
inlineconstexpr

Returns the number of elements this pool contains.

Returns
Number of elements in the pool.

◆ store()

template<typename T , size_t POOL_SIZE, Alignment ALIGNMENT = Alignment::NATURAL, template< typename, typename=void > class TypeSelector = Lock_free_type_selector>
void temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::store ( size_t  idx,
Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::Type  value,
std::memory_order  order = std::memory_order_seq_cst 
)
inline

Atomically replaces current value in an array at given index.

[in] idx Index of an element whose value is to be replaced. [in] value Value to store into the atomic variable. [in] order Memory order constraints to enforce.

Member Data Documentation

◆ m_lock_free

template<typename T , size_t POOL_SIZE, Alignment ALIGNMENT = Alignment::NATURAL, template< typename, typename=void > class TypeSelector = Lock_free_type_selector>
std::array<Lock_free_type<T, ALIGNMENT, TypeSelector>, POOL_SIZE> temptable::Lock_free_pool< T, POOL_SIZE, ALIGNMENT, TypeSelector >::m_lock_free
private

The documentation for this class was generated from the following file: