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.
Public Member Functions | |
| SingleChunkRegionTracker ()=default | |
| SingleChunkRegionTracker (ByteSpan region) | |
| void | SetRegion (ByteSpan region) |
| std::optional< OwnedChunk > | GetChunk (size_t size) |
| void | Destroy () override |
| ByteSpan | Region () const override |
| void * | AllocateChunkClass () override |
| void | DeallocateChunkClass (void *chunk) override |
Deallocates a pointer returned by AllocateChunkClass. | |
Public Member Functions inherited from pw::multibuf::v1::ChunkRegionTracker | |
| 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. | |
|
default |
Default constructor.
Callers must call SetRegion before calling GetChunk.
|
inlineexplicit |
Constructs a region tracker with a single Chunk that maps to region, which must outlive this tracker and any OwnedChunk it creates.
|
inlineoverridevirtual |
Returns a pointer to sizeof(Chunk) bytes with alignas(Chunk). Returns nullptr on failure.
Implements pw::multibuf::v1::ChunkRegionTracker.
|
inlineoverridevirtual |
Deallocates a pointer returned by AllocateChunkClass.
Implements pw::multibuf::v1::ChunkRegionTracker.
|
inlineoverridevirtual |
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::v1::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.
|
inlineoverridevirtual |
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::v1::ChunkRegionTracker.
|
inline |
Sets the region used to provide the chunk.
At most one region may be set by this method or a constructor.