bit::memory
|
A cache containing an intrinsically linked list of memory_blocks. More...
#include <memory_block_cache.hpp>
Public Member Functions | |
memory_block_cache () noexcept | |
Default constructs a block cache. | |
memory_block_cache (memory_block_cache &&other) noexcept=default | |
Move-constructs a memory_block_cache from an existing one. More... | |
memory_block_cache (const memory_block_cache &other)=delete | |
memory_block_cache & | operator= (memory_block_cache &&other)=delete |
memory_block_cache & | operator= (const memory_block_cache &other)=delete |
bool | empty () const noexcept |
Returns whether or not this memory_block_cache is empty. More... | |
std::size_t | size () const noexcept |
Returns the number of memory_blocks in this cache. More... | |
std::size_t | size_bytes () const noexcept |
Returns the size in bytes of all the memory_blocks in the cache. More... | |
bool | contains (const void *ptr) const noexcept |
Evaluates whether ptr exists within this memory_block_cache. More... | |
const memory_block & | peek () const noexcept |
Views the front memory block of this cache. More... | |
owner< memory_block > | request_block () noexcept |
Requests a block from the current block cache. More... | |
template<typename BlockAllocator > | |
owner< memory_block > | request_block (BlockAllocator &alloc) |
Requests a block from. More... | |
void | steal_block (memory_block_cache &other) noexcept |
Acquires an entry from another cache. More... | |
void | store_block (owner< memory_block > block) noexcept |
Stores an allocated block inside this memory_block_cache. More... | |
void | swap (memory_block_cache &other) noexcept |
Swaps this with another block cache. More... | |
A cache containing an intrinsically linked list of memory_blocks.
Blocks in this cache are not guaranteed to all be of the same size. Memory blocks may originate from different allocators, and represent different regions of memory – however this is not the recommended practice.
Every memory_block in the memory_block_cache must be aligned to at least alignof(memory_block)
bytes – otherwise it is undefined behavior
Definition at line 60 of file memory_block_cache.hpp.
|
defaultnoexcept |
Move-constructs a memory_block_cache from an existing one.
other | the other memory_block_cache to move |
|
noexcept |
Evaluates whether ptr
exists within this memory_block_cache.
ptr | the pointer to evaluate |
true
whether ptr
|
noexcept |
Returns whether or not this memory_block_cache is empty.
true
if this memory_block_cache is empty, false
otherwise
|
noexcept |
Views the front memory block of this cache.
|
noexcept |
Requests a block from the current block cache.
If one can be provided, the block is released from this cache and is now owned by the accessor
owner<memory_block> bit::memory::memory_block_cache::request_block | ( | BlockAllocator & | alloc | ) |
Requests a block from.
alloc | the allocator |
|
noexcept |
Returns the number of memory_blocks in this cache.
This function is lazily computed, and is written with O(n)
complexity
|
noexcept |
Returns the size in bytes of all the memory_blocks in the cache.
|
noexcept |
Acquires an entry from another cache.
other | the cache to acquire the entry from |
|
noexcept |
Stores an allocated block inside this memory_block_cache.
block.data()
points to memory that is aligned to at least alignof(memory_block)
bytes.block
points to a valid memory_blockblock | the block to store |
|
noexcept |
Swaps this with another block cache.
other | the other memory_block_cache to swap with |