memory
|
A memory arena that manages huge memory blocks for a higher-level allocator.
Some allocators like memory_stack work on huge memory blocks, this class manages them fro those allocators. It uses a BlockAllocator for the allocation of those blocks. The memory blocks in use are put onto a stack like structure, deallocation will pop from the top, so it is only possible to deallocate the last allocated block of the arena. By default, blocks are not really deallocated but stored in a cache. This can be disabled with the second template parameter, passing it uncached_arena (or false
) disables it, cached_arena (or true
) enables it explicitly.
Typedefs | |
using | allocator_type = BlockAllocator |
using | is_cached = std::integral_constant< bool, Cached > |
Static Functions | |
static constexpr std::size_t | min_block_size (std::size_t byte_size) noexcept |
Member Functions | |
template<typename... Args> | |
memory_arena (std::size_t block_size, Args &&... args) | |
~memory_arena () noexcept | |
memory_block | allocate_block () |
memory_block | current_block () const noexcept |
void | deallocate_block () noexcept |
bool | owns (const void *ptr) const noexcept |
void | shrink_to_fit () noexcept |
std::size_t | capacity () const noexcept |
std::size_t | cache_size () const noexcept |
std::size_t | size () const noexcept |
std::size_t | next_block_size () const noexcept |
allocator_type & | get_allocator () noexcept |
memory_arena (memory_arena &&other) noexcept | |
memory_arena & | operator= (memory_arena &&other) noexcept |
|
explicit |
block_size
must be greater than min_block_size(0)
and other requirements depending on the BlockAllocator. BlockAllocator
.
|
noexcept |
|
noexcept |
|
staticconstexprnoexcept |
min_block_size(n)
, the resulting capacity will be exactly n
. byte_size
must be a positive number.
|
noexcept |
memory_block allocate_block | ( | ) |
|
noexcept |
|
noexcept |
|
noexcept |
ptr
is in memory owned by the arena.
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |