Core class that represents a memory pool.
More...
Core class that represents a memory pool.
◆ MemoryPool() [1/2]
Nz::MemoryPool::MemoryPool |
( |
unsigned int |
blockSize, |
|
|
unsigned int |
size = 1024 , |
|
|
bool |
canGrow = true |
|
) |
| |
|
inline |
Constructs a MemoryPool object.
- Parameters
-
blockSize | Size of blocks that will be allocated |
size | Size of the pool |
canGrow | Determine if the pool can allocate more memory |
◆ MemoryPool() [2/2]
Constructs a MemoryPool object by move semantic.
- Parameters
-
◆ Allocate()
void * Nz::MemoryPool::Allocate |
( |
unsigned int |
size | ) |
|
|
inline |
Allocates enough memory for the size and returns a pointer to it.
- Returns
- A pointer to memory allocated
- Parameters
-
◆ Delete()
template<typename T >
void Nz::MemoryPool::Delete |
( |
T * |
ptr | ) |
|
Deletes the memory represented by the poiner.
Calls the destructor of the object before releasing it
◆ Free()
void Nz::MemoryPool::Free |
( |
void * |
ptr | ) |
|
|
inline |
Frees the memory represented by the poiner.
If the pool gets empty after the call and we are the child of another pool, we commit suicide. If the pointer does not own to a block of the pool, operator delete is called
◆ GetBlockSize()
unsigned int Nz::MemoryPool::GetBlockSize |
( |
| ) |
const |
|
inline |
Gets the block size.
- Returns
- Size of the blocks
◆ GetFreeBlocks()
unsigned int Nz::MemoryPool::GetFreeBlocks |
( |
| ) |
const |
|
inline |
Gets the number of free blocks.
- Returns
- Number of free blocks in the pool
◆ GetSize()
unsigned int Nz::MemoryPool::GetSize |
( |
| ) |
const |
|
inline |
Gets the pool size.
- Returns
- Size of the pool
◆ New()
template<typename T , typename... Args>
T * Nz::MemoryPool::New |
( |
Args &&... |
args | ) |
|
|
inline |
Creates a new value of type T with arguments.
- Returns
- Pointer to the allocated object
- Parameters
-
args | Arguments for the new object |
◆ operator=()
Assigns the content of another pool by move semantic.
- Returns
- A reference to this
- Parameters
-
pool | Other pool to move into this |
The documentation for this class was generated from the following files: