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

fixed size pool allocator More...

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

Public Types

typedef T value_type
 value_type definition More...
 

Public Member Functions

 TrivialPoolAllocator (T pool[], size_t poolSize)
 Ctor. More...
 
T * allocate ()
 Allocates memory out of the memory pool. More...
 
void deallocate (T *obj)
 Deallocates the pool memory pointed by ptr. More...
 
bool isFull () const
 get is allocator full flag More...
 
size_t remainingSize () const
 return the remaining size of Ts 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::TrivialPoolAllocator< 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 TrivialPoolAllocator object.

Template Parameters
Tis a trivial type like a struct used as the element to allocate. The bytes size of T must be greator or equal sizeof(Node)

Member Typedef Documentation

◆ value_type

template<typename T >
typedef T imt::base::core::util::TrivialPoolAllocator< T >::value_type

value_type definition

Constructor & Destructor Documentation

◆ TrivialPoolAllocator()

template<typename T >
imt::base::core::util::TrivialPoolAllocator< T >::TrivialPoolAllocator ( 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::TrivialPoolAllocator< T >::allocate
inline

Allocates memory out of the memory pool.

Allocates the a number of bytes and returns a pointer to the memory location. The number of bytes must be <= elemSize.

Returns
Pointer to the memory location. This function returns 0 in case of out of memory or in case of bytes <= elemSize missmatch.

◆ capacity()

template<typename T >
size_t imt::base::core::util::TrivialPoolAllocator< 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::TrivialPoolAllocator< T >::deallocate ( T *  obj)
inline

Deallocates the pool memory pointed by ptr.

Parameters
objReferenz to the object, which points to the memory to deallocate. (void*& allows writing ptr)

◆ getValueSize()

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

get size of T

Returns
size of T in bytes

◆ isFull()

template<typename T >
bool imt::base::core::util::TrivialPoolAllocator< 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::TrivialPoolAllocator< T >::remainingSize ( ) const
inline

return the remaining size of Ts

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

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