#include <header_chunk_region_tracker.h>
Public Member Functions | |
ByteSpan | Region () const final |
![]() | |
std::optional< OwnedChunk > | CreateFirstChunk () |
Static Public Member Functions | |
static std::optional< OwnedChunk > | AllocateRegionAsChunk (allocator::Allocator &alloc, size_t size) |
static HeaderChunkRegionTracker * | AllocateRegion (allocator::Allocator &alloc, size_t size) |
Protected Member Functions | |
void | Destroy () final |
void * | AllocateChunkClass () final |
void | DeallocateChunkClass (void *ptr) final |
Deallocates a pointer returned by AllocateChunkClass . | |
virtual void | Destroy ()=0 |
virtual ByteSpan | Region () const =0 |
virtual void * | AllocateChunkClass ()=0 |
virtual void | DeallocateChunkClass (void *)=0 |
Deallocates a pointer returned by AllocateChunkClass . | |
A ChunkRegionTracker
which stores its Chunk
and region metadata in a allocator::Allocator
allocation alongside the data.
This is useful when testing and when there is no need for asynchronous allocation.
|
inlinefinalprotectedvirtual |
Returns a pointer to sizeof(Chunk)
bytes with alignas(Chunk)
. Returns nullptr
on failure.
Implements pw::multibuf::ChunkRegionTracker.
|
inlinestatic |
Allocates a new region of size
bytes in alloc
.
The underlyiing allocation will also store the HeaderChunkRegionTracker
itself. The allocated memory must not outlive the provided allocator alloc
.
Returns a pointer to the newly-created HeaderChunkRegionTracker
or nullptr
if the allocation failed.
|
inlinestatic |
Allocates a new Chunk
region of size
bytes in alloc
.
The underlyiing allocation will also store the HeaderChunkRegionTracker
itself. The allocated memory must not outlive the provided allocator alloc
.
Returns the newly-created OwnedChunk
if successful.
|
inlinefinalprotectedvirtual |
Deallocates a pointer returned by AllocateChunkClass
.
Implements pw::multibuf::ChunkRegionTracker.
|
inlinefinalprotectedvirtual |
Destroys the ChunkRegionTracker
.
Typical implementations will call std::destroy_at(this)
and then free the memory associated with the region and the tracker.
Implements pw::multibuf::ChunkRegionTracker.
|
inlinefinalvirtual |
Returns the entire span of the region being managed.
Chunk
s referencing this tracker will not expand beyond this region, nor into one another's portions of the region.
This region does not provide any alignment guarantees by default.
This region must not change for the lifetime of this ChunkRegionTracker
.
Implements pw::multibuf::ChunkRegionTracker.