This class acts as a Memory pool and initializes memory at program initialization.
More...
|
auto | requestMemory (unsigned int idx) -> type |
| Returns memory during data processing to the requesting stage. More...
|
|
auto | returnMemory (type &&img) -> void |
| This function reenters the data element in the memory pool. More...
|
|
auto | registerStage (const int &numberOfElements, const size_t &size) -> int |
| This function is called at program initialization, when a stage needs memory during data processing. More...
|
|
auto | freeMemory (const unsigned int idx) -> void |
| When the classes are destroyed, this functions frees the allocated memory. More...
|
|
| ~Singleton () |
|
template<class MemoryManager>
class glados::MemoryPool< MemoryManager >
This class acts as a Memory pool and initializes memory at program initialization.
At program initialization the requesting stage asks for a given number of elements of a given data type and size. The MemoryPool allocates the memory and provides during data processing, when a stage asks for it.
Definition at line 50 of file MemoryPool.h.
template<class MemoryManager >
auto glados::MemoryPool< MemoryManager >::registerStage |
( |
const int & |
numberOfElements, |
|
|
const size_t & |
size |
|
) |
| -> int |
|
inline |
This function is called at program initialization, when a stage needs memory during data processing.
All stages that need memory need to register in MemoryManager. Stages need to tell, which size of memory they need and how many elements. The MemoryManager then allocates the memory and manages it.
- Parameters
-
[in] | numberOfElements | number of elements that shall be allocated by the MemoryManager |
[in] | size | size of memory that needs to be allocated per element |
- Returns
- identifier, where
Definition at line 110 of file MemoryPool.h.
template<class MemoryManager >
Returns memory during data processing to the requesting stage.
All stages that are registered in MemoryPool can request memory with this function. If the stage is not registered, an exception will be thrown. Memory allocation occurs only, if stage did not request enough memory during registration. In all other cases no allocation, no copy operations will be performed.
- Parameters
-
[in] | idx | stage that requests memory, got an id during registration. This id needs to passed to this function. |
Definition at line 68 of file MemoryPool.h.
template<class MemoryManager >
This function reenters the data element in the memory pool.
This function gets an image, e.g. when image gets out of scope and stores it in the memory pool vector, where it originally came from
- Parameters
-
[in] | img | Image, that shall be returned into memory pool for reuse |
Definition at line 90 of file MemoryPool.h.