Base class for memory pool.
More...
#include </home/travis/build/forGGe/theCore/lib/allocators/export/ecl/pool.hpp>
|
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...
|
|
|
virtual uint8_t * | real_alloc (size_t n, size_t align, size_t obj_sz)=0 |
| Allocates chunk with respect to given alingment. More...
|
|
virtual void | real_dealloc (uint8_t *p, size_t n, size_t obj_sz)=0 |
| Deallocates chunk of given address and length. More...
|
|
Base class for memory pool.
Provides interfaces for allocation and deallocation of objects of given type. This abstraction helps split handing of type requirement and memory allocations into separate entities.
- See also
- ecl::pool
◆ ~pool_base()
ecl::pool_base::~pool_base |
( |
| ) |
|
|
virtual |
◆ aligned_alloc()
template<typename T >
T * ecl::pool_base::aligned_alloc |
( |
size_t |
n | ) |
|
Allocates memory suitable for type T, with respect to its aligment.
This method will allocate continuous block of memory that suitable for given type and count of objects of given type. Start address of that block will be aligned with respect to the given type.
- Template Parameters
-
T | A type whose object will be placed in the allocated memory. |
- Parameters
-
[in] | n | Count of objects that will be placed in the allocated memory. Behavior is undefined if given count is equal to 0. |
- Returns
- nullptr if there is no space for given type and count in the pool. Valid pointer returned otherwise.
◆ deallocate()
template<typename T >
void ecl::pool_base::deallocate |
( |
T * |
p, |
|
|
size_t |
n |
|
) |
| |
Deallocates memory, previously allocated by aligned_alloc.
- Precondition
- Memory pool with allocated block of given type, starting from given address and with total size that corresponds to amount of objects that where requested in call to aligned_alloc()
- Postcondition
- Memory pool with deallocated (invalidated) block in given address with given object count and object type.
- Template Parameters
-
T | A type whose object was placed in the pool memory. block was originally allocated for other type. Undefined behavior otherwise. |
- Parameters
-
[in] | p | A pointer to a block of previously allocated memory. If given pointer is outside of pool or it points to a block that wasn't allocated by alligned_alloc() then behavior is undefined. |
[in] | n | Count of objects to deallocate. Must match the value previously passed to alligned_alloc(). Undefined behavior otherwise. |
◆ real_alloc()
virtual uint8_t* ecl::pool_base::real_alloc |
( |
size_t |
n, |
|
|
size_t |
align, |
|
|
size_t |
obj_sz |
|
) |
| |
|
protectedpure virtual |
◆ real_dealloc()
virtual void ecl::pool_base::real_dealloc |
( |
uint8_t * |
p, |
|
|
size_t |
n, |
|
|
size_t |
obj_sz |
|
) |
| |
|
protectedpure virtual |
The documentation for this class was generated from the following files: