dispenso 1.4.1
A library for task parallelism
Loading...
Searching...
No Matches
dispenso::ConcurrentObjectArena< T, Index, alignment > Struct Template Reference

#include <concurrent_object_arena.h>

Public Member Functions

 ConcurrentObjectArena (const Index minBuffSize)
 
 ConcurrentObjectArena (const ConcurrentObjectArena< T, Index, alignment > &other)
 
 ConcurrentObjectArena (ConcurrentObjectArena< T, Index, alignment > &&other) noexcept
 
Index grow_by (const Index delta)
 
Index size () const
 
Index capacity () const
 
Index numBuffers () const
 
const T * getBuffer (const Index index) const
 
T * getBuffer (const Index index)
 
Index getBufferSize (const Index index) const
 

Detailed Description

template<class T, class Index = size_t, size_t alignment = dispenso::kCacheLineSize>
struct dispenso::ConcurrentObjectArena< T, Index, alignment >

ConcurrentObjectArena is an indexed sequence container that allows concurrent insertion to its end. Insertion never invalidates pointers or references to the rest of the elements. As opposet to std::vector, the elements of a ConcurrentObjectArena are not stored contiguously. In memory it is sequence of individually allocated fixed-size arrays, with additional bookkeeping. The size of arrays is always power of two (to optimize indexed access)

   buffers  |<────     bufferSize      ────>|
     ┌─┐    ┌──────────────────────────────┐
     │*├───>│                              │
     ├─┤    ├──────────────────────────────┤
     │*├───>│                              │
     ├─┤    ├──────────────────────────────┤
     │*├───>│                              │
     └─┘    └──────────────────────────────┘
*

Definition at line 57 of file concurrent_object_arena.h.

Constructor & Destructor Documentation

◆ ConcurrentObjectArena() [1/3]

template<class T , class Index = size_t, size_t alignment = dispenso::kCacheLineSize>
dispenso::ConcurrentObjectArena< T, Index, alignment >::ConcurrentObjectArena ( const Index minBuffSize)
inlineexplicit

Construct a ConcurrentObjectArena with given or bigger contiguous array size

Parameters
minBuffSizeThe minimum size of the internal buffer. If given size is not power of 2 the closest bigger power of two would be chosen.

Definition at line 65 of file concurrent_object_arena.h.

◆ ConcurrentObjectArena() [2/3]

template<class T , class Index = size_t, size_t alignment = dispenso::kCacheLineSize>
dispenso::ConcurrentObjectArena< T, Index, alignment >::ConcurrentObjectArena ( const ConcurrentObjectArena< T, Index, alignment > & other)
inline

Copy constructor

Definition at line 83 of file concurrent_object_arena.h.

◆ ConcurrentObjectArena() [3/3]

template<class T , class Index = size_t, size_t alignment = dispenso::kCacheLineSize>
dispenso::ConcurrentObjectArena< T, Index, alignment >::ConcurrentObjectArena ( ConcurrentObjectArena< T, Index, alignment > && other)
inlinenoexcept

Move constructor

Definition at line 108 of file concurrent_object_arena.h.

◆ ~ConcurrentObjectArena()

template<class T , class Index = size_t, size_t alignment = dispenso::kCacheLineSize>
dispenso::ConcurrentObjectArena< T, Index, alignment >::~ConcurrentObjectArena ( )
inline

Definition at line 120 of file concurrent_object_arena.h.

Member Function Documentation

◆ capacity()

template<class T , class Index = size_t, size_t alignment = dispenso::kCacheLineSize>
Index dispenso::ConcurrentObjectArena< T, Index, alignment >::capacity ( ) const
inline

The current capacity of the object arena. Concurrency safe.

Returns
The current capacity. Note that elements can be appended concurrently

Definition at line 226 of file concurrent_object_arena.h.

◆ getBuffer() [1/2]

template<class T , class Index = size_t, size_t alignment = dispenso::kCacheLineSize>
T * dispenso::ConcurrentObjectArena< T, Index, alignment >::getBuffer ( const Index index)
inline

Get the pointer to the buffer. Concurrency safe.

Parameters
indexindex of the buffer
Returns
The pointer to the buffer.

Definition at line 252 of file concurrent_object_arena.h.

◆ getBuffer() [2/2]

template<class T , class Index = size_t, size_t alignment = dispenso::kCacheLineSize>
const T * dispenso::ConcurrentObjectArena< T, Index, alignment >::getBuffer ( const Index index) const
inline

Get the pointer to the buffer. Concurrency safe.

Parameters
indexindex of the buffer
Returns
The pointer to the buffer.

Definition at line 243 of file concurrent_object_arena.h.

◆ getBufferSize()

template<class T , class Index = size_t, size_t alignment = dispenso::kCacheLineSize>
Index dispenso::ConcurrentObjectArena< T, Index, alignment >::getBufferSize ( const Index index) const
inline

Get the used buffer size. not concurrency safe.

Parameters
indexindex of the buffer.
Returns
The used buffer size.

Definition at line 261 of file concurrent_object_arena.h.

◆ grow_by()

template<class T , class Index = size_t, size_t alignment = dispenso::kCacheLineSize>
Index dispenso::ConcurrentObjectArena< T, Index, alignment >::grow_by ( const Index delta)
inline

Grow a container

This function is thread safe and never invalidates pointers or references to the rest of the elements. It is lock-free if new elements can be placed in current buffer. It locks if it allocates a new buffer.

Parameters
deltaNew size of the container will be delta elements bigger.
Returns
index of the first element of the allocated group.

Definition at line 159 of file concurrent_object_arena.h.

◆ numBuffers()

template<class T , class Index = size_t, size_t alignment = dispenso::kCacheLineSize>
Index dispenso::ConcurrentObjectArena< T, Index, alignment >::numBuffers ( ) const
inline

Number of the internal buffers. Concurrency safe.

Returns
The current number of buffers. Note that buffers can be appended concurrently

Definition at line 234 of file concurrent_object_arena.h.

◆ size()

template<class T , class Index = size_t, size_t alignment = dispenso::kCacheLineSize>
Index dispenso::ConcurrentObjectArena< T, Index, alignment >::size ( ) const
inline

Get the size of the object arena. Concurrency safe.

Returns
The number of elements in the object arena. Note that elements can be appended concurrently with this call.

Definition at line 218 of file concurrent_object_arena.h.


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