libuav original
Dependents: UAVCAN UAVCAN_Subscriber
PoolAllocator< PoolSize, BlockSize, RaiiSynchronizer > Class Template Reference
Classic implementation of a pool allocator (Meyers). More...
#include <dynamic_memory.hpp>
Inherits uavcan::IPoolAllocator, and uavcan::Noncopyable.
Public Member Functions | |
virtual uint16_t | getBlockCapacity () const |
Returns the maximum number of blocks this allocator can allocate. | |
uint16_t | getNumUsedBlocks () const |
Return the number of blocks that are currently allocated/unallocated. | |
uint16_t | getPeakNumUsedBlocks () const |
Returns the maximum number of blocks that were ever allocated at the same time. |
Detailed Description
template<std::size_t PoolSize, uint8_t BlockSize, typename RaiiSynchronizer = char>
class uavcan::PoolAllocator< PoolSize, BlockSize, RaiiSynchronizer >
Classic implementation of a pool allocator (Meyers).
The allocator can be made thread-safe (optional) by means of providing a RAII-lock type via the second template argument. The allocator uses the lock only to access the shared state, therefore critical sections are only a few cycles long, which implies that it should be acceptable to use hardware IRQ disabling instead of a mutex for performance reasons. For example, an IRQ-based RAII-lock type can be implemented as follows: struct RaiiSynchronizer { RaiiSynchronizer() { __disable_irq(); } ~RaiiSynchronizer() { __enable_irq(); } };
Definition at line 51 of file dynamic_memory.hpp.
Member Function Documentation
virtual uint16_t getBlockCapacity | ( | ) | const [virtual] |
Returns the maximum number of blocks this allocator can allocate.
Implements IPoolAllocator.
Definition at line 80 of file dynamic_memory.hpp.
uint16_t getNumUsedBlocks | ( | ) | const |
Return the number of blocks that are currently allocated/unallocated.
Definition at line 85 of file dynamic_memory.hpp.
uint16_t getPeakNumUsedBlocks | ( | ) | const |
Returns the maximum number of blocks that were ever allocated at the same time.
Definition at line 101 of file dynamic_memory.hpp.
Generated on Tue Jul 12 2022 17:17:37 by 1.7.2