Native QF Memory Pool. More...
#include <qmpool.h>
Public Member Functions | |
| void | QMPool_init (QMPool *const me, void *const poolSto, uint_fast32_t const poolSize, uint_fast16_t const blockSize) |
| Initializes the native QF memory pool. | |
| void * | QMPool_get (QMPool *const me, uint_fast16_t const margin, uint_fast8_t const qsId) |
| Obtain a memory block from a memory pool. | |
| void | QMPool_put (QMPool *const me, void *const block, uint_fast8_t const qsId) |
| Recycles a memory block back to a memory pool. | |
| uint16_t | QMPool_getUse (QMPool const *const me) |
| uint16_t | QMPool_getFree (QMPool const *const me) |
| uint16_t | QMPool_getMin (QMPool const *const me) |
Private Attributes | |
| void ** | start |
| Start of the memory managed by this memory pool. | |
| void ** | end |
| End of the memory managed by this memory pool. | |
| void ** | freeHead |
| Head of linked list of free memory blocks. | |
| QMPoolSize | blockSize |
| Memory block size [bytes] held by this fixed-size pool. | |
| QMPoolCtr | nTot |
| Total number of memory blocks in this pool. | |
| QMPoolCtr | nFree |
| Number of free memory blocks remaining in the pool at this point. | |
| QMPoolCtr | nMin |
| Minimum number of free blocks ever present in this pool. | |
Native QF Memory Pool.
Details
A fixed block-size memory pool is a very fast and efficient data structure for dynamic allocation of fixed block-size chunks of memory. A memory pool offers fast and deterministic allocation and recycling of memory blocks and is not subject to fragmentation.
The QMPool class describes the native QF memory pool, which can be used as the event pool for mutable event allocation, or as a fast, deterministic fixed block-size heap for any other objects in your application.
| void QMPool_init | ( | QMPool *const | me, |
| void *const | poolSto, | ||
| uint_fast32_t const | poolSize, | ||
| uint_fast16_t const | blockSize ) |
Initializes the native QF memory pool.
Details
Initialize a fixed block-size memory pool by providing it with the pool memory to manage, size of this memory, and the block size.
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | poolSto | pointer to the memory buffer for pool storage |
| [in] | poolSize | size of the storage buffer in bytes |
| [in] | blockSize | fixed-size of the memory blocks in bytes |
| void * QMPool_get | ( | QMPool *const | me, |
| uint_fast16_t const | margin, | ||
| uint_fast8_t const | qsId ) |
Obtain a memory block from a memory pool.
Details
The function allocates a memory block from the pool and returns a pointer to the block back to the caller.
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | margin | the minimum number of unused blocks still available in the pool after the allocation. |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
| void QMPool_put | ( | QMPool *const | me, |
| void *const | block, | ||
| uint_fast8_t const | qsId ) |
Recycles a memory block back to a memory pool.
Details
Recycle a memory block to the fixed block-size memory pool.
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | block | pointer to the memory block that is being recycled |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |