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) |
|
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.
|
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.