The Gaudi Framework
master (37c0b60a)
|
A fast memory arena that does not track deallocations. More...
#include </builds/gaudi/Gaudi/GaudiKernel/include/Gaudi/Arena/Monotonic.h>
Public Member Functions | |
Monotonic (std::size_t next_block_size) noexcept | |
Construct an arena whose first block have approximately the given size. More... | |
~Monotonic () noexcept | |
Monotonic (Monotonic &&)=delete | |
Monotonic (Monotonic const &)=delete | |
Monotonic & | operator= (Monotonic &&)=delete |
Monotonic & | operator= (Monotonic const &)=delete |
template<std::size_t ReqAlign> | |
std::byte * | allocate (std::size_t n) |
Return an aligned point to n bytes of memory. More... | |
constexpr void | deallocate (std::byte *, std::size_t) noexcept |
Deallocations are not tracked, so this is a no-op! More... | |
void | reset () noexcept |
Signal that this arena may start re-using the memory resources. More... | |
std::size_t | capacity () const noexcept |
Query how much memory is owned by this arena, in bytes. More... | |
std::size_t | size () const noexcept |
Query how much memory was used from this arena, in bytes. More... | |
std::size_t | num_blocks () const noexcept |
Query how many blocks of memory this arena owns. More... | |
std::size_t | num_allocations () const noexcept |
Query how many allocations this arena has served. More... | |
Static Public Attributes | |
static constexpr std::size_t | alignment = Alignment |
Private Attributes | |
std::size_t | m_next_block_size {} |
Size (in bytes) of the next block to be allocated. More... | |
std::size_t | m_allocations { 0 } |
Number of allocation requests served by this arena. More... | |
std::byte * | m_current { nullptr } |
Current position in the current block, or nullptr if there is no current block. More... | |
std::byte * | m_current_end { nullptr } |
One byte past the end of the current block, or nullptr if it doesn't exist. More... | |
boost::container::small_vector< gsl::span< std::byte >, 1 > | m_all_blocks |
All memory blocks owned by this arena. More... | |
Static Private Attributes | |
static constexpr std::size_t | growth_factor = 2 |
Approximate factor by which each block is larger than its predecessor. More... | |
A fast memory arena that does not track deallocations.
This is a memory arena suitable for use with Gaudi::Allocators::Arena. It allocates memory from an upstream resource in blocks of geometrically increasing size and serves allocation requests from those blocks. Deallocations are not tracked, so the memory footprint of a Monotonic arena increases monotonically until either it is destroyed or its reset() method is called. All requests are served with alignment specified in the template parameter.
Efficiently support stateful upstream allocators, probably by putting an instance of the upstream allocator in a boost::compressed_pair.
Use the given UpstreamAllocator to serve dynamic allocations required by boost::container::small_vector.
Definition at line 46 of file Monotonic.h.
|
inlinenoexcept |
Construct an arena whose first block have approximately the given size.
This constructor does not trigger any allocation.
Definition at line 74 of file Monotonic.h.
|
inlinenoexcept |
Definition at line 77 of file Monotonic.h.
|
delete |
|
delete |
|
inline |
Return an aligned point to n bytes of memory.
This may trigger allocation from the upstream resource.
Definition at line 92 of file Monotonic.h.
|
inlinenoexcept |
|
inlineconstexprnoexcept |
Deallocations are not tracked, so this is a no-op!
Definition at line 117 of file Monotonic.h.
|
inlinenoexcept |
|
inlinenoexcept |
|
delete |
|
delete |
|
inlinenoexcept |
Signal that this arena may start re-using the memory resources.
Definition at line 126 of file Monotonic.h.
|
inlinenoexcept |
Query how much memory was used from this arena, in bytes.
Definition at line 152 of file Monotonic.h.
|
staticconstexpr |
Definition at line 69 of file Monotonic.h.
|
staticconstexprprivate |
Approximate factor by which each block is larger than its predecessor.
Definition at line 66 of file Monotonic.h.
|
private |
All memory blocks owned by this arena.
Definition at line 63 of file Monotonic.h.
|
private |
Number of allocation requests served by this arena.
Definition at line 54 of file Monotonic.h.
|
private |
Current position in the current block, or nullptr if there is no current block.
Definition at line 57 of file Monotonic.h.
|
private |
One byte past the end of the current block, or nullptr if it doesn't exist.
Definition at line 60 of file Monotonic.h.
|
private |
Size (in bytes) of the next block to be allocated.
Definition at line 51 of file Monotonic.h.