libstdc++
|
#include <memory_resource>
Public Member Functions | |
monotonic_buffer_resource (const monotonic_buffer_resource &)=delete | |
monotonic_buffer_resource (memory_resource *__upstream) noexcept | |
monotonic_buffer_resource (size_t __initial_size) noexcept | |
monotonic_buffer_resource (size_t __initial_size, memory_resource *__upstream) noexcept | |
monotonic_buffer_resource (void *__buffer, size_t __buffer_size) noexcept | |
monotonic_buffer_resource (void *__buffer, size_t __buffer_size, memory_resource *__upstream) noexcept | |
void * | allocate (size_t __bytes, size_t __alignment=_S_max_align) |
void | deallocate (void *__p, size_t __bytes, size_t __alignment=_S_max_align) |
bool | is_equal (const memory_resource &__other) const noexcept |
monotonic_buffer_resource & | operator= (const monotonic_buffer_resource &)=delete |
void | release () noexcept |
memory_resource * | upstream_resource () const noexcept |
Protected Member Functions | |
void * | do_allocate (size_t __bytes, size_t __alignment) override |
void | do_deallocate (void *, size_t, size_t) override |
bool | do_is_equal (const memory_resource &__other) const noexcept override |
A memory resource that allocates from a fixed-size buffer.
The main feature of a pmr::monotonic_buffer_resource
is that its do_deallocate
does nothing. This makes it very fast because there is no need to manage a free list, and every allocation simply returns a new block of memory, rather than searching for a suitably-sized free block. Because deallocating is a no-op, the amount of memory used by the resource only grows until release()
(or the destructor) is called to return all memory to upstream.
A monotonic_buffer_resource
can be initialized with a buffer that will be used to satisfy all allocation requests, until the buffer is full. After that a new buffer will be allocated from the upstream resource. By using a stack buffer and pmr::null_memory_resource()
as the upstream you can get a memory resource that only uses the stack and never dynamically allocates.
Definition at line 339 of file memory_resource.
|
inlineexplicitnoexcept |
Definition at line 343 of file memory_resource.
|
inlinenoexcept |
Definition at line 348 of file memory_resource.
|
inlinenoexcept |
Definition at line 358 of file memory_resource.
|
inlinenoexcept |
Definition at line 370 of file memory_resource.
|
inlineexplicitnoexcept |
Definition at line 375 of file memory_resource.
|
inlinenoexcept |
Definition at line 379 of file memory_resource.
|
inlinenodiscardinherited |
Definition at line 76 of file memory_resource.h.
|
inlineinherited |
Definition at line 81 of file memory_resource.h.
|
inlineoverrideprotectedvirtual |
Implements std::pmr::memory_resource.
Definition at line 416 of file memory_resource.
|
inlineoverrideprotectedvirtual |
Implements std::pmr::memory_resource.
Definition at line 433 of file memory_resource.
|
inlineoverrideprotectedvirtualnoexcept |
Implements std::pmr::memory_resource.
Definition at line 437 of file memory_resource.
|
inlinenodiscardnoexceptinherited |
Definition at line 87 of file memory_resource.h.
|
inlinenoexcept |
Definition at line 391 of file memory_resource.
|
inlinenoexcept |
Definition at line 410 of file memory_resource.