An RAII handle to a contiguous slice of data that mimics v1::OwnedChunk.
This type can be used as a drop-in replacement for v1::OwnedChunk while migrating to using pw_multibuf/v2.
Public Member Functions | |
| OwnedChunk (Allocator &metadata_allocator, const SharedPtr< std::byte[]> &data) | |
| OwnedChunk (const OwnedChunk &)=delete | |
| OwnedChunk & | operator= (const OwnedChunk &)=delete |
| OwnedChunk (OwnedChunk &&other)=default | |
| OwnedChunk & | operator= (OwnedChunk &&other)=default |
| std::byte * | data () |
| const std::byte * | data () const |
| size_t | size () const |
| std::byte & | operator[] (size_t index) |
| std::byte | operator[] (size_t index) const |
| Chunk & | operator* () |
| const Chunk & | operator* () const |
| Chunk * | operator-> () |
| const Chunk * | operator-> () const |
| std::byte * | begin () |
| const std::byte * | begin () const |
| const std::byte * | cbegin () const |
| std::byte * | end () |
| const std::byte * | end () const |
| const std::byte * | cend () const |
| void | Release () |
| std::optional< Chunk > | Take () && |
Friends | |
| class | Chunk |
|
inline |
Decrements the reference count on the underlying chunk of data and empties this handle so that span() now returns an empty (zero-sized) span.
Does not modify the underlying data, but may cause it to be deallocated if this was the only remaining Chunk referring to its region.
This method is equivalent to { Chunk _unused = std::move(chunk_ref); }
This method will acquire a mutex and is not IRQ safe.
|
inline |
Returns the memory contained by this object's Chunk and empties this OwnedChunk without releasing the underlying memory.
This is similar to v1::OwnedChunk::Take, except that returns a std::optional<Chunk> instead of a Chunk*.