Dataflow Runtime API  3.1.1.0
Classes | Public Member Functions | Static Public Member Functions | List of all members
imt::base::core::util::ObjectPoolAllocator< T > Class Template Reference

fixed size pool allocator More...

#include <Imt.Base.Core.Util/ObjectPoolAllocator.h>

Public Member Functions

 ObjectPoolAllocator (T pool[], size_t poolSize)
 Ctor. More...
 
T * allocate ()
 Instantiates an object out of the memory pool. More...
 
void deallocate (T *obj)
 Deallocates the pool memory pointed by obj. More...
 
bool isFull () const
 get is allocator full flag More...
 
size_t remainingSize () const
 return the remaining size of Ts More...
 
const void * endAddr () const
 returns the end address More...
 
const void * startAddr () const
 returns the start address More...
 
size_t capacity () const
 return the maixmal size More...
 

Static Public Member Functions

static size_t getValueSize ()
 get size of T More...
 

Detailed Description

template<typename T>
class imt::base::core::util::ObjectPoolAllocator< T >

fixed size pool allocator

Some IMT constraints are vioalted with this class

This fixed size pool allocator can be used as a kind of heap for object with the same size. E.g. an object of this class can be used behind a stack, queue and so on. The memory ressource used for this allocator must have a constant size and start address during the lifetime of an ObjectPoolAllocator object.

Template Parameters
Tis a non-trivial type like a class used with ctor and so on. The bytes size of T must be greator or equal sizeof(Node)

Constructor & Destructor Documentation

◆ ObjectPoolAllocator()

template<typename T >
imt::base::core::util::ObjectPoolAllocator< T >::ObjectPoolAllocator ( pool[],
size_t  poolSize 
)

Ctor.

Parameters
poolobject pool / array start address
poolSizebuffer size

Member Function Documentation

◆ allocate()

template<typename T >
T * imt::base::core::util::ObjectPoolAllocator< T >::allocate
inline

Instantiates an object out of the memory pool.

Allocates the a number of bytes, calls the constructor of the object (new) and returns a pointer to it. The number of bytes must be <= elemSize.

Returns
Pointer to the object. This function returns 0 in case of out of memory.

◆ capacity()

template<typename T >
size_t imt::base::core::util::ObjectPoolAllocator< T >::capacity ( ) const
inline

return the maixmal size

Returns
number of how many Ts can be placed in this allocator

◆ deallocate()

template<typename T >
void imt::base::core::util::ObjectPoolAllocator< T >::deallocate ( T *  obj)
inline

Deallocates the pool memory pointed by obj.

Parameters
objReference to the object, which points to the memory to deallocate.

◆ endAddr()

template<typename T >
const void* imt::base::core::util::ObjectPoolAllocator< T >::endAddr ( ) const
inline

returns the end address

Returns
the end address is calculated as pool start address + size*sizeof(T)

◆ getValueSize()

template<typename T >
static size_t imt::base::core::util::ObjectPoolAllocator< T >::getValueSize ( )
inlinestatic

get size of T

Returns
size of T in bytes

◆ isFull()

template<typename T >
bool imt::base::core::util::ObjectPoolAllocator< T >::isFull ( ) const
inline

get is allocator full flag

Returns
true if the allocator is full, otherwise false is returned

◆ remainingSize()

template<typename T >
size_t imt::base::core::util::ObjectPoolAllocator< T >::remainingSize ( ) const
inline

return the remaining size of Ts

Returns
the count of Ts, the allocator object is able to allocate

◆ startAddr()

template<typename T >
const void* imt::base::core::util::ObjectPoolAllocator< T >::startAddr ( ) const
inline

returns the start address

Returns
the end address is equal to the pool start address

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