Isle
|
[AI] Fixed-size memory pool template for fast allocation and deallocation. More...
#include <mxmemorypool.h>
Public Member Functions | |
MxMemoryPool () | |
[AI] Constructor. More... | |
~MxMemoryPool () | |
[AI] Destructor. More... | |
MxResult | Allocate () |
[AI] Allocates the memory pool according to template parameters. More... | |
MxU8 * | Get () |
[AI] Gets a pointer to the next available block in the memory pool. More... | |
void | Release (MxU8 *p_buf) |
[AI] Releases the block at the given pointer back into the pool. More... | |
MxU32 | GetPoolSize () const |
[AI] Returns the number of blocks in the pool. More... | |
[AI] Fixed-size memory pool template for fast allocation and deallocation.
[AI] The MxMemoryPool class manages a pool of buffers of a fixed block size and count, providing fast and efficient memory allocation and release. Internally, a bitset keeps track of used/free blocks and returns pointers to available blocks on request.
BS | [AI] Block size, in kilobytes (each allocation is BS*1024 bytes) |
NB | [AI] Number of blocks in the pool |
Definition at line 21 of file mxmemorypool.h.
|
inline |
[AI] Constructor.
Initializes an empty pool with the specified block size.
[AI] The actual allocation is deferred until Allocate is called.
Definition at line 27 of file mxmemorypool.h.
|
inline |
[AI] Destructor.
Destroys the memory pool and releases its memory.
Definition at line 32 of file mxmemorypool.h.
MxResult MxMemoryPool< BS, NB >::Allocate |
[AI] Allocates the memory pool according to template parameters.
[AI] Allocates a contiguous memory block sufficient for NB blocks of BS*1024 bytes each. Panics if called more than once or with zero block size/count.
Definition at line 71 of file mxmemorypool.h.
MxU8 * MxMemoryPool< BS, NB >::Get |
[AI] Gets a pointer to the next available block in the memory pool.
[AI] Scans the block reference bitset for a free block, marks it as used and returns pointer to its start.
Definition at line 84 of file mxmemorypool.h.
|
inline |
[AI] Returns the number of blocks in the pool.
[AI] Returns the size reported by the MxBitset managing block references.
Definition at line 62 of file mxmemorypool.h.
void MxMemoryPool< BS, NB >::Release | ( | MxU8 * | p_buf | ) |
[AI] Releases the block at the given pointer back into the pool.
p_buf | Pointer within the memory pool to be released. [AI] |
[AI] Calculates the block index from the pointer, marks it as free in the block reference bitset.
Definition at line 104 of file mxmemorypool.h.