Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
MemoryPool< T, pool_sz > Class Template Reference
[MemoryPool class]
Define and manage fixed-size memory pools of objects of a given type. More...
#include <MemoryPool.h>
Inherits NonCopyable< MemoryPool< T, pool_sz > >.
Public Member Functions | |
MemoryPool () | |
Create and Initialize a memory pool. | |
~MemoryPool () | |
Destroy a memory pool. | |
T * | alloc (void) |
Allocate a memory block of type T from a memory pool. | |
T * | calloc (void) |
Allocate a memory block of type T from a memory pool and set memory block to zero. | |
osStatus | free (T *block) |
Free a memory block. | |
Private Member Functions | |
MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &) | |
NonCopyable copy constructor. | |
MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator | |
NonCopyable copy assignment operator. |
Detailed Description
template<typename T, uint32_t pool_sz>
class rtos::MemoryPool< T, pool_sz >
Define and manage fixed-size memory pools of objects of a given type.
- Template Parameters:
-
T data type of a single object (element). queue_sz maximum number of objects (elements) in the memory pool.
- Note:
- Memory considerations: The memory pool data store and control structures will be created on current thread's stack, both for the mbed OS and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
Definition at line 50 of file MemoryPool.h.
Constructor & Destructor Documentation
MemoryPool | ( | ) |
Create and Initialize a memory pool.
- Note:
- You cannot call this function from ISR context.
Definition at line 57 of file MemoryPool.h.
~MemoryPool | ( | ) |
Destroy a memory pool.
- Note:
- You cannot call this function from ISR context.
Definition at line 73 of file MemoryPool.h.
Member Function Documentation
T* alloc | ( | void | ) |
Allocate a memory block of type T from a memory pool.
- Returns:
- address of the allocated memory block or NULL in case of no memory available.
- Note:
- You may call this function from ISR context.
Definition at line 82 of file MemoryPool.h.
T* calloc | ( | void | ) |
Allocate a memory block of type T from a memory pool and set memory block to zero.
- Returns:
- address of the allocated memory block or NULL in case of no memory available.
- Note:
- You may call this function from ISR context.
Definition at line 91 of file MemoryPool.h.
osStatus free | ( | T * | block ) |
Free a memory block.
- Parameters:
-
block address of the allocated memory block to be freed.
- Returns:
- osOK on successful deallocation, osErrorParameter if given memory block id is NULL or invalid, or osErrorResource if given memory block is in an invalid memory pool state.
- Note:
- You may call this function from ISR context.
Definition at line 107 of file MemoryPool.h.
Generated on Tue Jul 12 2022 14:27:16 by
