Native QF Memory Pool. More...
#include <qmpool.hpp>
Public Member Functions | |
| QMPool () noexcept | |
| Default constructor of QP::QMPool. | |
| void | init (void *const poolSto, std::uint_fast32_t const poolSize, std::uint_fast16_t const blockSize) noexcept |
| Initializes the native QF memory pool. | |
| void * | get (std::uint_fast16_t const margin, std::uint_fast8_t const qsId) noexcept |
| Obtain a memory block from a memory pool. | |
| void | put (void *const block, std::uint_fast8_t const qsId) noexcept |
| Recycles a memory block back to a memory pool. | |
| QMPoolSize | getBlockSize () const noexcept |
| std::uint16_t | getUse () const noexcept |
| std::uint16_t | getFree () const noexcept |
| std::uint16_t | getMin () const noexcept |
| void * | getFromISR (std::uint_fast16_t const margin, std::uint_fast8_t const qsId) noexcept |
| void | putFromISR (void *const b, std::uint_fast8_t const qsId) noexcept |
Private Attributes | |
| void ** | m_start |
| Start of the memory managed by this memory pool. | |
| void ** | m_end |
| End of the memory managed by this memory pool. | |
| void ** | m_freeHead |
| QMPoolSize | m_blockSize |
| Memory block size [bytes] held by this fixed-size pool. | |
| QMPoolCtr | m_nTot |
| Total number of memory blocks in this pool. | |
| QMPoolCtr | m_nFree |
| Number of free memory blocks remaining in the pool at this point. | |
| QMPoolCtr | m_nMin |
| Minimum number of free blocks ever present in this pool. | |
Friends | |
| class | QS |
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 QP::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.
Definition at line 67 of file qmpool.hpp.
|
noexcept |
Default constructor of QP::QMPool.
Definition at line 48 of file qf_mem.cpp.
|
noexcept |
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] | 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 |
Definition at line 58 of file qf_mem.cpp.
|
noexcept |
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] | 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) |
Definition at line 121 of file qf_mem.cpp.
|
noexcept |
Recycles a memory block back to a memory pool.
Details
Recycle a memory block to the fixed block-size memory pool.
| [in] | block | pointer to the memory block that is being recycled |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
Definition at line 200 of file qf_mem.cpp.
|
noexcept |
Definition at line 269 of file qf_mem.cpp.
|
noexcept |
Definition at line 251 of file qf_mem.cpp.
|
noexcept |
Definition at line 257 of file qf_mem.cpp.
|
noexcept |
Definition at line 263 of file qf_mem.cpp.
|
noexcept |
|
noexcept |
|
friend |
Definition at line 105 of file qmpool.hpp.
|
private |
Start of the memory managed by this memory pool.
Definition at line 69 of file qmpool.hpp.
|
private |
End of the memory managed by this memory pool.
Definition at line 70 of file qmpool.hpp.
|
private |
Definition at line 71 of file qmpool.hpp.
|
private |
Memory block size [bytes] held by this fixed-size pool.
Definition at line 72 of file qmpool.hpp.
|
private |
Total number of memory blocks in this pool.
Definition at line 73 of file qmpool.hpp.
|
private |
Number of free memory blocks remaining in the pool at this point.
Definition at line 74 of file qmpool.hpp.
|
private |
Minimum number of free blocks ever present in this pool.
Details
This attribute remembers the low watermark of the pool, which provides a valuable information for sizing event pools. (
Definition at line 75 of file qmpool.hpp.