Hermes
0.9.5-beta
Hierarchical Distributed I/O Buffering System
|
#include <memory_management.h>
Public Member Functions | |
ScopedTemporaryMemory (const ScopedTemporaryMemory &)=delete | |
ScopedTemporaryMemory & | operator= (const ScopedTemporaryMemory &)=delete |
ScopedTemporaryMemory (Arena *backing_arena) | |
~ScopedTemporaryMemory () | |
operator Arena * () | |
Public Attributes | |
Arena * | arena |
size_t | used |
A block of memory that can be used dynamically, but is deleted when exiting the current scope.
ScopedTemporaryMemory wraps an existing Arena. You can pass an instance of it as you would normally pass an Arena instance to PushSize and PushArray. The difference is that the memory is reclaimed once the scope in which ScopedTemporaryMemory is declared is exited. Note that there is no actual free
happening. Rather, the existing Arena's used
parameter is reset to where it was before the ScopedTemporaryMemory was created.
Example:
|
inlineexplicit |
Creates a ScopedTemporaryMemory from an existing, backing Arena.
backing_arena | The existing Arena backing the temporary memory. |
|
inline |
Destructor. Restores the backing Arena's bytes in use to the saved used
value, effectively reclaiming the memory that was used in this scope.
|
inline |
Allows passing a ScopedTemporaryMemory to functions that take an Arena without an explicit cast.
size_t hermes::ScopedTemporaryMemory::used |
The stored number of bytes in use by the backing Arena