This allocator creates a pool of fixed-sized chunk entries for allocations.
More...
#include <pool_allocator.hpp>
This allocator creates a pool of fixed-sized chunk entries for allocations.
- Satisfies
- ExtendedAllocator
Definition at line 56 of file pool_allocator.hpp.
◆ max_alignment
The max alignment is limited to 128 bytes due to an internal requirement that it stores the offset information
Definition at line 67 of file pool_allocator.hpp.
◆ pool_allocator() [1/2]
bit::memory::pool_allocator::pool_allocator |
( |
std::size_t |
chunk_size, |
|
|
memory_block |
block |
|
) |
| |
Constructs a pool allocator with chunk sizes of chunk_size
, in the arena indicated by block
.
- Parameters
-
chunk_size | the size of each entry in the pool allocator |
block | the block to allocate from |
◆ pool_allocator() [2/2]
bit::memory::pool_allocator::pool_allocator |
( |
pool_allocator && |
other | ) |
|
|
defaultnoexcept |
Move-constructs the pool_allocator from another allocator.
- Parameters
-
other | the other allocator to move |
◆ deallocate()
void bit::memory::pool_allocator::deallocate |
( |
owner< void *> |
p, |
|
|
std::size_t |
size |
|
) |
| |
Deallocates memory previously allocated from a call to try_allocate
.
- Parameters
-
p | the pointer to the memory to deallocate |
size | the size of the memory previously provided to try_allocate |
◆ info()
Gets the info about this allocator.
This defaults to 'pool_allocator'. Use a named_pool_allocator to override this
- Returns
- the info for this allocator
◆ max_size()
std::size_t bit::memory::pool_allocator::max_size |
( |
| ) |
const |
|
noexcept |
Determines the max size that this allocator can allocate.
- Returns
- the max size
◆ owns()
bool bit::memory::pool_allocator::owns |
( |
const void * |
p | ) |
const |
|
noexcept |
Determines whether the pointer p
is owned by this allocator.
- Returns
true
if the pointer p
is originally from this allocator
◆ try_allocate()
owner<void*> bit::memory::pool_allocator::try_allocate |
( |
std::size_t |
size, |
|
|
std::size_t |
align, |
|
|
std::size_t |
offset = 0 |
|
) |
| |
|
noexcept |
Tries to allocate size
bytes with the alignment of align
, offset by offset
.
- Parameters
-
size | the requested size of the allocation |
align | the requested alignment of the allocation |
offset | the amount to offset the alignment |
- Returns
- pointer to the allocated memory, or
nullptr
on failure
The documentation for this class was generated from the following file: