join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::BasicPool< Count, Size > Struct Template Reference

free-list pool operating over a pre-existing memory region. More...

#include <allocator.hpp>

Collaboration diagram for join::BasicPool< Count, Size >:

Public Types

using Chunk = BasicChunk<Size>
 
using Segment = BasicSegment<Size>
 

Public Member Functions

 BasicPool (void *ptr) noexcept
 initialize the pool over an existing memory region.
 
 BasicPool (const BasicPool &other)=delete
 copy constructor.
 
BasicPooloperator= (const BasicPool &other)=delete
 copy assignment operator.
 
 BasicPool (BasicPool &&other) noexcept
 move constructor.
 
BasicPooloperator= (BasicPool &&other) noexcept
 move assignment operator.
 
 ~BasicPool ()=default
 destroy instance.
 
void * pop () noexcept
 pop a chunk from the pool.
 
void push (void *p) noexcept
 push a chunk back to the pool.
 
bool owns (void *p) const noexcept
 check if the pointer belongs to this pool.
 

Public Attributes

Segment_segment = nullptr
 pointer into the mapped region.
 

Static Public Attributes

static constexpr size_t _count = Count
 total number of chunks per pool.
 
static constexpr size_t _size = Size
 size of each chunk in bytes.
 
static constexpr size_t _stride = sizeof (Chunk)
 size in bytes between two consecutive chunks.
 
static constexpr size_t _total = sizeof (Segment) + _stride * _count
 total bytes required in the mapped region for this pool.
 

Detailed Description

template<size_t Count, size_t Size>
struct join::BasicPool< Count, Size >

free-list pool operating over a pre-existing memory region.

Member Typedef Documentation

◆ Chunk

template<size_t Count, size_t Size>
using join::BasicPool< Count, Size >::Chunk = BasicChunk<Size>

◆ Segment

template<size_t Count, size_t Size>
using join::BasicPool< Count, Size >::Segment = BasicSegment<Size>

Constructor & Destructor Documentation

◆ BasicPool() [1/3]

template<size_t Count, size_t Size>
join::BasicPool< Count, Size >::BasicPool ( void * ptr)
inlineexplicitnoexcept

initialize the pool over an existing memory region.

Parameters
ptrpointer to the start of the region.

◆ BasicPool() [2/3]

template<size_t Count, size_t Size>
join::BasicPool< Count, Size >::BasicPool ( const BasicPool< Count, Size > & other)
delete

copy constructor.

Parameters
otherother object to copy.

◆ BasicPool() [3/3]

template<size_t Count, size_t Size>
join::BasicPool< Count, Size >::BasicPool ( BasicPool< Count, Size > && other)
inlinenoexcept

move constructor.

Parameters
otherother object to move.

◆ ~BasicPool()

template<size_t Count, size_t Size>
join::BasicPool< Count, Size >::~BasicPool ( )
default

destroy instance.

Member Function Documentation

◆ operator=() [1/2]

template<size_t Count, size_t Size>
BasicPool & join::BasicPool< Count, Size >::operator= ( BasicPool< Count, Size > && other)
inlinenoexcept

move assignment operator.

Parameters
otherother object to move.
Returns
this.

◆ operator=() [2/2]

template<size_t Count, size_t Size>
BasicPool & join::BasicPool< Count, Size >::operator= ( const BasicPool< Count, Size > & other)
delete

copy assignment operator.

Parameters
otherother object to copy.

◆ owns()

template<size_t Count, size_t Size>
bool join::BasicPool< Count, Size >::owns ( void * p) const
inlinenoexcept

check if the pointer belongs to this pool.

Parameters
ppointer to check.
Returns
true if the pointer belongs to this pool, false otherwise.

◆ pop()

template<size_t Count, size_t Size>
void * join::BasicPool< Count, Size >::pop ( )
inlinenoexcept

pop a chunk from the pool.

Returns
pointer to the chunk, or nullptr if exhausted.

◆ push()

template<size_t Count, size_t Size>
void join::BasicPool< Count, Size >::push ( void * p)
inlinenoexcept

push a chunk back to the pool.

Parameters
ppointer to the chunk to return.

Member Data Documentation

◆ _count

template<size_t Count, size_t Size>
size_t join::BasicPool< Count, Size >::_count = Count
staticconstexpr

total number of chunks per pool.

◆ _segment

template<size_t Count, size_t Size>
Segment* join::BasicPool< Count, Size >::_segment = nullptr

pointer into the mapped region.

◆ _size

template<size_t Count, size_t Size>
size_t join::BasicPool< Count, Size >::_size = Size
staticconstexpr

size of each chunk in bytes.

◆ _stride

template<size_t Count, size_t Size>
size_t join::BasicPool< Count, Size >::_stride = sizeof (Chunk)
staticconstexpr

size in bytes between two consecutive chunks.

◆ _total

template<size_t Count, size_t Size>
size_t join::BasicPool< Count, Size >::_total = sizeof (Segment) + _stride * _count
staticconstexpr

total bytes required in the mapped region for this pool.


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