27#ifndef TEMPTABLE_LOCK_FREE_POOL_H
28#define TEMPTABLE_LOCK_FREE_POOL_H
43template <
typename T,
size_t POOL_SIZE,
45 template <
typename,
typename =
void>
class TypeSelector =
46 Lock_free_type_selector>
48 std::array<Lock_free_type<T, ALIGNMENT, TypeSelector>, POOL_SIZE>
m_lock_free;
59 for (
auto &v :
m_lock_free) v.m_value = default_value;
77 std::memory_order order = std::memory_order_seq_cst) {
89 size_t idx, std::memory_order order = std::memory_order_seq_cst)
const {
107 std::memory_order order = std::memory_order_seq_cst) {
108 return m_lock_free[idx].m_value.compare_exchange_strong(expected, desired,
116 constexpr size_t size()
const {
return POOL_SIZE; }
Lock-free pool which consists of POOL_SIZE Lock_free_type elements.
Definition: lock_free_pool.h:47
constexpr size_t size() const
Returns the number of elements this pool contains.
Definition: lock_free_pool.h:116
Lock_free_pool(const Lock_free_pool &)=delete
Copy-constructor and copy-assignment operator are disabled.
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,...
Definition: lock_free_pool.h:105
Lock_free_pool(Lock_free_pool::Type default_value)
Constructor.
Definition: lock_free_pool.h:58
Lock_free_pool()
Default constructor.
Definition: lock_free_pool.h:55
typename Lock_free_type< T, ALIGNMENT, TypeSelector >::Type Type
Definition: lock_free_pool.h:51
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.
Definition: lock_free_pool.h:88
Lock_free_pool(Lock_free_pool &&)=delete
Ditto for move-constructor and move-assignment operator.
Lock_free_pool & operator=(Lock_free_pool &&)=delete
Lock_free_pool & operator=(const 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.
Definition: lock_free_pool.h:76
std::array< Lock_free_type< T, ALIGNMENT, TypeSelector >, POOL_SIZE > m_lock_free
Definition: lock_free_pool.h:48
Lock-free type (selection) implementation.
Definition: allocator.h:45
Alignment
Enum class describing alignment-requirements.
Definition: lock_free_type.h:75
typename TypeSelector< T >::Type Type
Definition: lock_free_type.h:305