nrfcxx
0.1.0
C++-17 Framework for Nordic nRF5 Devices
|
RAII class to maintain a shared memory pool within a block scope. More...
#include <nrfcxx/utility.hpp>
Public Member Functions | |
~scoped () | |
Contained pool is cleared on destruction. | |
RAII class to maintain a shared memory pool within a block scope.
This is used when there is a global "scratch" pool available for transient use by a variety of components. It ensures that the pool is empty when the holder instance is constructed, and cleared when the holder instance is destructed.
Usage:
memory_pool scratch{}; scratch.configure(...); // ... { auto scope = scratch.make_scoped(); auto buffer = static_cast<uint8_t*>(scratch.allocate(23)); // ... } // pool is again unused