theCore C++ embedded framework
ecl::pool< blk_sz, blk_cnt > Class Template Reference

Holds given buffer as a pool. More...

#include </home/travis/build/forGGe/theCore/lib/allocators/export/ecl/pool.hpp>

Inheritance diagram for ecl::pool< blk_sz, blk_cnt >:
Collaboration diagram for ecl::pool< blk_sz, blk_cnt >:

Public Member Functions

 pool ()
 Constructs pool. More...
 
 ~pool ()
 Destructs pool. More...
 
uint8_t * real_alloc (size_t n, size_t align, size_t obj_sz) override
 Allocates chunk with respect to given alingment. More...
 
void real_dealloc (uint8_t *p, size_t n, size_t obj_sz) override
 Deallocates chunk of given address and length. More...
 
pooloperator= (pool &)=delete
 
 pool (const pool &)=delete
 
- Public Member Functions inherited from ecl::pool_base
template<typename T >
T * aligned_alloc (size_t n)
 Allocates memory suitable for type T, with respect to its aligment. More...
 
template<typename T >
void deallocate (T *p, size_t n)
 Deallocates memory, previously allocated by aligned_alloc. More...
 
virtual ~pool_base ()
 Destroys a pool. More...
 

Additional Inherited Members

Detailed Description

template<size_t blk_sz, size_t blk_cnt>
class ecl::pool< blk_sz, blk_cnt >

Holds given buffer as a pool.

Object of this pool can be shared by different instances of an allocator. Refer to a wiki for further info: here

Constructor & Destructor Documentation

◆ pool() [1/2]

template<size_t blk_sz, size_t blk_cnt>
ecl::pool< blk_sz, blk_cnt >::pool ( )

Constructs pool.

◆ ~pool()

template<size_t blk_sz, size_t blk_cnt>
ecl::pool< blk_sz, blk_cnt >::~pool ( )

Destructs pool.

◆ pool() [2/2]

template<size_t blk_sz, size_t blk_cnt>
ecl::pool< blk_sz, blk_cnt >::pool ( const pool< blk_sz, blk_cnt > &  )
delete

Member Function Documentation

◆ real_alloc()

template<size_t blk_sz, size_t blk_cnt>
uint8_t * ecl::pool< blk_sz, blk_cnt >::real_alloc ( size_t  n,
size_t  align,
size_t  obj_sz 
)
overridevirtual

Allocates chunk with respect to given alingment.

Parameters
[in]nObject count.
[in]alignRequired align.
[in]obj_szSize of single object.
Returns
nullptr if there is no space for given type and count in the pool. Valid pointer returned otherwise.
See also
aligned_alloc()

Implements ecl::pool_base.

◆ real_dealloc()

template<size_t blk_sz, size_t blk_cnt>
void ecl::pool< blk_sz, blk_cnt >::real_dealloc ( uint8_t *  p,
size_t  n,
size_t  obj_sz 
)
overridevirtual

Deallocates chunk of given address and length.

Length of chunk is determined by multiplication count of objects by object size.

Parameters
[in]pAddress of a chunk. Must be valid address, returned Previously by real_alloc().
[in]nObjects count. Must be the same as passed to real_alloc() when given chunk was allocated.
[in]obj_szSize of single object. Must be the same as passed to real_alloc() when given chunk was allocated.
See also
deallocate()

Implements ecl::pool_base.

◆ operator=()

template<size_t blk_sz, size_t blk_cnt>
pool& ecl::pool< blk_sz, blk_cnt >::operator= ( pool< blk_sz, blk_cnt > &  )
delete

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