nrfcxx  0.1.0
C++-17 Framework for Nordic nRF5 Devices
Public Member Functions
nrfcxx::utility::memory_pool< ALIGN_BITS >::scoped Class Reference

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.
 

Detailed Description

template<unsigned int ALIGN_BITS = 2>
class nrfcxx::utility::memory_pool< ALIGN_BITS >::scoped

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

The documentation for this class was generated from the following file: