#include <dynamic_memory.hpp>
Classes | |
union | Node |
Public Member Functions | |
void * | allocate (std::size_t size) |
virtual void * | allocate (std::size_t size) |
void | deallocate (const void *ptr) |
virtual void | deallocate (const void *ptr) |
virtual uint16_t | getBlockCapacity () const |
uint16_t | getNumFreeBlocks () const |
uint16_t | getNumUsedBlocks () const |
uint16_t | getPeakNumUsedBlocks () const |
PoolAllocator () | |
![]() | |
virtual | ~IPoolAllocator () |
Static Public Attributes | |
static const uint16_t | NumBlocks = PoolSize / BlockSize |
Private Attributes | |
Node * | free_list_ |
uint16_t | max_used_ |
union { | |
long double _aligner1 | |
long long _aligner2 | |
Node _aligner3 | |
uint8_t bytes [PoolSize] | |
} | pool_ |
uint16_t | used_ |
Additional Inherited Members | |
![]() | |
Noncopyable () | |
~Noncopyable () | |
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.
uavcan::PoolAllocator< PoolSize, BlockSize, RaiiSynchronizer >::PoolAllocator |
Definition at line 142 of file dynamic_memory.hpp.
|
inlinevirtual |
Implements uavcan::IPoolAllocator.
Definition at line 34 of file coverity_scan_model.cpp.
|
virtual |
Implements uavcan::IPoolAllocator.
Definition at line 160 of file dynamic_memory.hpp.
|
inlinevirtual |
Implements uavcan::IPoolAllocator.
Definition at line 39 of file coverity_scan_model.cpp.
|
virtual |
Implements uavcan::IPoolAllocator.
Definition at line 185 of file dynamic_memory.hpp.
|
inlinevirtual |
Returns the maximum number of blocks this allocator can allocate.
Implements uavcan::IPoolAllocator.
Definition at line 80 of file dynamic_memory.hpp.
|
inline |
Definition at line 91 of file dynamic_memory.hpp.
|
inline |
Return the number of blocks that are currently allocated/unallocated.
Definition at line 85 of file dynamic_memory.hpp.
|
inline |
Returns the maximum number of blocks that were ever allocated at the same time.
Definition at line 101 of file dynamic_memory.hpp.
long double uavcan::PoolAllocator< PoolSize, BlockSize, RaiiSynchronizer >::_aligner1 |
Definition at line 64 of file dynamic_memory.hpp.
long long uavcan::PoolAllocator< PoolSize, BlockSize, RaiiSynchronizer >::_aligner2 |
Definition at line 65 of file dynamic_memory.hpp.
Node uavcan::PoolAllocator< PoolSize, BlockSize, RaiiSynchronizer >::_aligner3 |
Definition at line 66 of file dynamic_memory.hpp.
uint8_t uavcan::PoolAllocator< PoolSize, BlockSize, RaiiSynchronizer >::bytes[PoolSize] |
Definition at line 63 of file dynamic_memory.hpp.
|
private |
Definition at line 60 of file dynamic_memory.hpp.
|
private |
Definition at line 70 of file dynamic_memory.hpp.
|
static |
Definition at line 73 of file dynamic_memory.hpp.
union { ... } uavcan::PoolAllocator< PoolSize, BlockSize, RaiiSynchronizer >::pool_ |
|
private |
Definition at line 69 of file dynamic_memory.hpp.