Define and manage fixed-size memory pools of objects of a given type. More...
#include <MemoryPool.h>
Public Member Functions | |
MemoryPool () | |
Create and Initialize a memory pool. More... | |
~MemoryPool () | |
Destroy a memory pool. More... | |
T * | alloc () |
Allocate a memory block from a memory pool, without blocking. More... | |
T * | try_alloc () |
Allocate a memory block from a memory pool, without blocking. More... | |
T * | alloc_for (uint32_t millisec) |
Allocate a memory block from a memory pool, optionally blocking. More... | |
T * | try_alloc_for (Kernel::Clock::duration_u32 rel_time) |
Allocate a memory block from a memory pool, optionally blocking. More... | |
T * | alloc_until (uint64_t millisec) |
Allocate a memory block from a memory pool, blocking. More... | |
T * | try_alloc_until (Kernel::Clock::time_point abs_time) |
Allocate a memory block from a memory pool, blocking. More... | |
T * | calloc () |
Allocate a memory block from a memory pool, without blocking, and set memory block to zero. More... | |
T * | try_calloc () |
Allocate a memory block from a memory pool, without blocking, and set memory block to zero. More... | |
T * | calloc_for (uint32_t millisec) |
Allocate a memory block from a memory pool, optionally blocking, and set memory block to zero. More... | |
T * | try_calloc_for (Kernel::Clock::duration_u32 rel_time) |
Allocate a memory block from a memory pool, optionally blocking, and set memory block to zero. More... | |
T * | calloc_until (uint64_t millisec) |
Allocate a memory block from a memory pool, blocking, and set memory block to zero. More... | |
T * | try_calloc_until (Kernel::Clock::time_point abs_time) |
Allocate a memory block from a memory pool, blocking, and set memory block to zero. More... | |
osStatus | free (T *block) |
Free a memory block. More... | |
Define and manage fixed-size memory pools of objects of a given type.
T | data type of a single object (element). |
queue_sz | maximum number of objects (elements) in the memory pool. |
Definition at line 59 of file MemoryPool.h.
MemoryPool | ( | ) |
Create and Initialize a memory pool.
Definition at line 66 of file MemoryPool.h.
~MemoryPool | ( | ) |
Destroy a memory pool.
Definition at line 82 of file MemoryPool.h.
T* alloc | ( | ) |
Allocate a memory block from a memory pool, without blocking.
Definition at line 94 of file MemoryPool.h.
T* alloc_for | ( | uint32_t | millisec | ) |
Allocate a memory block from a memory pool, optionally blocking.
millisec | timeout value (osWaitForever to wait forever) |
try_alloc_for
. For example use try_alloc_for(5s)
rather than alloc_for(5000)
. Definition at line 117 of file MemoryPool.h.
T* alloc_until | ( | uint64_t | millisec | ) |
Allocate a memory block from a memory pool, blocking.
millisec | absolute timeout time, referenced to Kernel::get_ms_count(). |
try_alloc_until
. For example use try_alloc_until(Kernel::Clock::now() + 5s)
rather than alloc_until(Kernel::get_ms_count() + 5000)
. Definition at line 146 of file MemoryPool.h.
T* calloc | ( | ) |
Allocate a memory block from a memory pool, without blocking, and set memory block to zero.
Definition at line 182 of file MemoryPool.h.
T* calloc_for | ( | uint32_t | millisec | ) |
Allocate a memory block from a memory pool, optionally blocking, and set memory block to zero.
millisec | timeout value (osWaitForever to wait forever) |
try_calloc_for
. For example use try_calloc_for(5s)
rather than calloc_for(5000)
. Definition at line 209 of file MemoryPool.h.
T* calloc_until | ( | uint64_t | millisec | ) |
Allocate a memory block from a memory pool, blocking, and set memory block to zero.
millisec | absolute timeout time, referenced to Kernel::get_ms_count(). |
try_calloc_until
. For example use try_calloc_until(Kernel::Clock::now() + 5s)
rather than calloc_until(Kernel::get_ms_count() + 5000)
. Definition at line 242 of file MemoryPool.h.
osStatus free | ( | T * | block | ) |
Free a memory block.
block | address of the allocated memory block to be freed. |
Definition at line 274 of file MemoryPool.h.
T* try_alloc | ( | ) |
Allocate a memory block from a memory pool, without blocking.
Definition at line 104 of file MemoryPool.h.
T* try_alloc_for | ( | Kernel::Clock::duration_u32 | rel_time | ) |
Allocate a memory block from a memory pool, optionally blocking.
rel_time | timeout value (Kernel::wait_for_u32_forever to wait forever) |
Definition at line 128 of file MemoryPool.h.
T* try_alloc_until | ( | Kernel::Clock::time_point | abs_time | ) |
Allocate a memory block from a memory pool, blocking.
abs_time | absolute timeout time, referenced to Kernel::Clock. |
Definition at line 161 of file MemoryPool.h.
T* try_calloc | ( | ) |
Allocate a memory block from a memory pool, without blocking, and set memory block to zero.
Definition at line 192 of file MemoryPool.h.
T* try_calloc_for | ( | Kernel::Clock::duration_u32 | rel_time | ) |
Allocate a memory block from a memory pool, optionally blocking, and set memory block to zero.
rel_time | timeout value (Kernel::wait_for_u32_forever to wait forever) |
Definition at line 220 of file MemoryPool.h.
T* try_calloc_until | ( | Kernel::Clock::time_point | abs_time | ) |
Allocate a memory block from a memory pool, blocking, and set memory block to zero.
abs_time | absolute timeout time, referenced to Kernel::Clock. |
Definition at line 257 of file MemoryPool.h.