Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions
MemoryPool< T, pool_sz > Class Template Reference

Define and manage fixed-size memory pools of objects of a given type. More...

#include <MemoryPool.h>

Inheritance diagram for MemoryPool< T, pool_sz >:
NonCopyable< MemoryPool< T, pool_sz > >

Public Member Functions

 MemoryPool ()
 Create and Initialize a memory pool. More...
 
 ~MemoryPool ()
 Destroy a memory pool. More...
 
T * alloc (void)
 Allocate a memory block of type T from a memory pool. More...
 
T * calloc (void)
 Allocate a memory block of type T from a memory pool and set memory block to zero. More...
 
osStatus free (T *block)
 Free a memory block. More...
 

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
Tdata type of a single object (element).
queue_szmaximum 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

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 83 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 93 of file MemoryPool.h.

osStatus free ( T *  block)

Free a memory block.

Parameters
blockaddress 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 110 of file MemoryPool.h.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.