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.
Dependents: qp_hangman qp_dpp qp_blinky
QMPool Class Reference
Native QF memory pool class. More...
#include <qp.h>
Public Member Functions | |
void | init (void *const poolSto, uint32_t const poolSize, QMPoolSize const blockSize) |
Initializes the native QF event pool. | |
void * | get (void) |
Obtains a memory block from a memory pool. | |
void | put (void *const b) |
Returns a memory block back to a memory pool. | |
QMPoolSize | getBlockSize (void) const |
return the fixed block-size of the blocks managed by this pool | |
Friends | |
class | QF |
Detailed Description
Native QF memory pool class.
This class describes the native QF memory pool, which can be used as the event pool for dynamic event allocation, or as a fast, deterministic fixed block-size heap for any other objects in your application.
The QMPool structure contains only data members for managing a memory pool, but does not contain the pool storage, which must be provided externally during the pool initialization.
The native QF event pool is configured by defining the macro QF_EPOOL_TYPE_ as QEQueue in the specific QF port header file.
Definition at line 804 of file qp.h.
Member Function Documentation
void* get | ( | void | ) |
Obtains a memory block from a memory pool.
The only parameter me is a pointer to the QMPool from which the block is requested. The function returns a pointer to the allocated memory block or NULL if no free blocks are available.
A allocated block must be returned to the same pool from which it has been allocated.
This function can be called from any task level or ISR level.
- Note:
- The memory pool me must be initialized before any events can be requested from it. Also, the QMPool::get() function uses internally a QF critical section, so you should be careful not to call it from within a critical section when nesting of critical section is not supported.
- See also:
- QMPool::put()
QMPoolSize getBlockSize | ( | void | ) | const |
void init | ( | void *const | poolSto, |
uint32_t const | poolSize, | ||
QMPoolSize const | blockSize | ||
) |
Initializes the native QF event pool.
The parameters are as follows: poolSto is the pool storage, poolSize is the size of the pool storage in bytes, and blockSize is the block size of this pool.
The caller of this method must make sure that the poolSto pointer is properly aligned. In particular, it must be possible to efficiently store a pointer at the location pointed to by poolSto. Internally, the QMPool::init() function rounds up the block size blockSize so that it can fit an integer number of pointers. This is done to achieve proper alignment of the blocks within the pool.
- Note:
- Due to the rounding of block size the actual capacity of the pool might be less than (poolSize / blockSize). You can check the capacity of the pool by calling the QF::getPoolMargin() function.
void put | ( | void *const | b ) |
Returns a memory block back to a memory pool.
This function can be called from any task level or ISR level.
- Note:
- The block must be allocated from the same memory pool to which it is returned. The QMPool::put() function raises an assertion if the returned pointer to the block points outside of the original memory buffer managed by the memory pool. Also, the QMPool::put() function uses internally a QF critical section, so you should be careful not to call it from within a critical section when nesting of critical section is not supported.
- See also:
- QMPool::get()
Generated on Wed Jul 13 2022 11:50:18 by
