Helper type that creates a single OwnedChunk from a region of memory and mimics v1::SingleChunkRegionTracker.
This type can be used as a drop-in replacement for v1::SingleChunkRegionTracker while migrating to using pw_multibuf/v2.
Public Member Functions | |
| SingleChunkRegionTracker () | |
| SingleChunkRegionTracker (ByteSpan region) | |
| ByteSpan | Region () const |
| std::optional< OwnedChunk > | GetChunk (size_t size) |
| virtual void | Destroy () |
| void | SetRegion (ByteSpan region) |
|
inline |
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.
|
inlinevirtual |
Destroys the ChunkRegionTracker.
Typical implementations will call std::destroy_at(this) and then free the memory associated with the region and the tracker.
Reimplemented from pw::multibuf::v1_adapter::internal::SingleChunkAllocator.
|
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.
| void pw::multibuf::v1_adapter::internal::ChunkAllocator::SetRegion | ( | ByteSpan | region | ) |
Sets the region used to provide chunks.
At most one region may be set by this method or a constructor.