#include <single_chunk_region_tracker.h>
Public Member Functions | |
SingleChunkRegionTracker (ByteSpan region) | |
std::optional< OwnedChunk > | GetChunk (size_t size) |
void | Destroy () final |
ByteSpan | Region () const final |
void * | AllocateChunkClass () final |
void | DeallocateChunkClass (void *chunk) final |
Deallocates a pointer returned by AllocateChunkClass . | |
![]() | |
std::optional< OwnedChunk > | CreateFirstChunk () |
Additional Inherited Members | |
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
that uses inline memory to create a single Chunk
with the only caveat that the provided Chunk
cannot be split. All attempts will result in std::nullopt
.
|
inlineexplicit |
Constructs a region tracker with a single Chunk
that maps to region
, which must outlive this tracker and any OwnedChunk
it creates.
|
inlinefinalvirtual |
Returns a pointer to sizeof(Chunk)
bytes with alignas(Chunk)
. Returns nullptr
on failure.
Implements pw::multibuf::ChunkRegionTracker.
|
inlinefinalvirtual |
Deallocates a pointer returned by AllocateChunkClass
.
Implements pw::multibuf::ChunkRegionTracker.
|
inlinefinalvirtual |
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.
|
inline |
Gets a Chunk
of a given size, which must be less than or equal to the provided region.
Returns: An OwnedChunk
if the Chunk
is free, otherwise std::nullopt
, in which case GetChunk()
can be called again.
|
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.