Foundation
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Foundation::Atomics::Pool< K, V, Tombstone > Class Template Reference

Atomic, bounded object pool with O(1) value mapping. More...

#include <Pool.hpp>

Public Member Functions

 Pool (size_t size, Allocator *alloc)
 Constructs a FreeList with the specified capacity and allocator.
 
bool Contains (K key) const
 Checks if the specified key exists and has a value.
 
VAt (K key)
 Retrieves a reference to the value associated with the given key. NOTE: Calling this function with a key that's not retrieved from pop() is undefined behavior.
 
V constAt (K key) const
 Retrieves a const reference to the value associated with the given key.
 
const K Pop ()
 
const Pair< K, V & > PopPair ()
 Allocates a Key that returns a pair of key and value reference.
 
void Free (K key)
 Frees the value associated with the specified key.
 

Private Attributes

const size_t mCapacity
 
MPMCQueue< KmKeys
 
Vector< VmValues
 
Vector< charmBitmap
 

Detailed Description

template<typename K, typename V, typename Tombstone = V>
class Foundation::Atomics::Pool< K, V, Tombstone >

Atomic, bounded object pool with O(1) value mapping.

Note
This is the atomic, lock-free version of Core::Pool. The pool has a fixed maximum size and will never allocate memory after construction. For an unbounded, lock-based implementation see Core::Pool.
Template Parameters
KKey type. Should be an integral type.
VValue type.
TombstoneTombstone value type for erased values.

Constructor & Destructor Documentation

◆ Pool()

template<typename K , typename V , typename Tombstone = V>
Foundation::Atomics::Pool< K, V, Tombstone >::Pool ( size_t  size,
Allocator alloc 
)
inline

Constructs a FreeList with the specified capacity and allocator.

Parameters
sizeThe maximum number of elements the FreeList can hold, which will be pre-allocated.
allocAllocator to use for internal allocations.

Member Function Documentation

◆ At() [1/2]

template<typename K , typename V , typename Tombstone = V>
V & Foundation::Atomics::Pool< K, V, Tombstone >::At ( K  key)
inline

Retrieves a reference to the value associated with the given key. NOTE: Calling this function with a key that's not retrieved from pop() is undefined behavior.

◆ At() [2/2]

template<typename K , typename V , typename Tombstone = V>
V const & Foundation::Atomics::Pool< K, V, Tombstone >::At ( K  key) const
inline

Retrieves a const reference to the value associated with the given key.

◆ Contains()

template<typename K , typename V , typename Tombstone = V>
bool Foundation::Atomics::Pool< K, V, Tombstone >::Contains ( K  key) const
inline

Checks if the specified key exists and has a value.

◆ Free()

template<typename K , typename V , typename Tombstone = V>
void Foundation::Atomics::Pool< K, V, Tombstone >::Free ( K  key)
inline

Frees the value associated with the specified key.

◆ Pop()

template<typename K , typename V , typename Tombstone = V>
const K Foundation::Atomics::Pool< K, V, Tombstone >::Pop ( )
inline

◆ PopPair()

template<typename K , typename V , typename Tombstone = V>
const Pair< K, V & > Foundation::Atomics::Pool< K, V, Tombstone >::PopPair ( )
inline

Allocates a Key that returns a pair of key and value reference.

Member Data Documentation

◆ mBitmap

template<typename K , typename V , typename Tombstone = V>
Vector<char> Foundation::Atomics::Pool< K, V, Tombstone >::mBitmap
private

◆ mCapacity

template<typename K , typename V , typename Tombstone = V>
const size_t Foundation::Atomics::Pool< K, V, Tombstone >::mCapacity
private

◆ mKeys

◆ mValues

template<typename K , typename V , typename Tombstone = V>
Vector<V> Foundation::Atomics::Pool< K, V, Tombstone >::mValues
private

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