| nrfcxx
    0.1.0
    C++-17 Framework for Nordic nRF5 Devices | 
Class supporting allocation from a fixed-size region. More...
#include <nrfcxx/utility.hpp>
| Data Structures | |
| class | scoped | 
| RAII class to maintain a shared memory pool within a block scope.  More... | |
| Public Types | |
| using | pool_type = memory_pool< ALIGN_BITS > | 
| Public Member Functions | |
| scoped | make_scoped () | 
| Construct an RAII holder that maintains the instance as a scratch pool.  More... | |
| constexpr | memory_pool () | 
| Construct the instance.  More... | |
| void | configure (void *begin, void *end, unsigned int code=FailSafeCode::MEMORY_POOL) | 
| Provide the allocation region and failsafe code.  More... | |
| void | clear () | 
| Release all allocations from the pool.  More... | |
| size_t | capacity () const | 
| Return the total number of bytes in the region (allocated plus unallocated). | |
| size_t | size () const | 
| Return the number of allocated bytes in the region. | |
| size_t | available () const | 
| Return the number of unallocated bytes in the region. | |
| void * | allocate (size_t span) | 
| Allocate a block of at least spanbytes.  More... | |
| Static Public Attributes | |
| static constexpr unsigned int | align_bits = ALIGN_BITS | 
| The number of bits used for alignment of the return pointers. | |
Class supporting allocation from a fixed-size region.
This capability is intended to support allocation of aligned variable-sized blocks of memory from an externally supplied region. A prime use case is populating runtime state structures corresponding to enabled capabilities when an application is being initialized.
Allocation is done from a region that is supplied externally during configuration. Attempts to allocate more space than is available will result in a fail-safe reset using a code provided along with the region. API is available to release all allocations from the region at once, but individual allocations cannot be released.
| ALIGN_BITS | initializes align_bits. | 
| 
 | inlineconstexpr | 
Construct the instance.
A newly-constructed instance does not have an associated region. configure() must be called before allocate() is invoked. Violation of this requirement will produce a failsafe reset.
| 
 | inline | 
Allocate a block of at least span bytes. 
If the allocation cannot be satisfied the system will failsafe reset using the code passed in configure().
| 
 | inline | 
Release all allocations from the pool.
After invoking this pointers returned from allocate() are invalidated and must not be dereferenced.
| 
 | inline | 
Provide the allocation region and failsafe code.
This method must be invoked before allocate().
| begin | a pointer to the start of the space available for allocation. | 
| end | a pointer just past the end of the space available for allocation. | 
| code | the codevalue to pass to failsafe() if an unsatisfiable allocation is made. | 
| 
 | inline | 
Construct an RAII holder that maintains the instance as a scratch pool.
The system will failsafe if the pool has allocations when the holder is constructed.
The pool will be cleared when the holder is destructed.
 1.8.16
 1.8.16