C/C++ API Reference
Loading...
Searching...
No Matches
pw::multibuf::v1_adapter::OwnedChunk Class Reference

Overview

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 Types

using element_type = std::byte
 
using value_type = std::byte
 
using size_type = size_t
 
using difference_type = ptrdiff_t
 
using pointer = std::byte *
 
using const_pointer = const std::byte *
 
using reference = std::byte &
 
using const_reference = const std::byte &
 
using iterator = std::byte *
 
using const_iterator = const std::byte *
 
using reverse_iterator = std::byte *
 
using const_reverse_iterator = const std::byte *
 

Public Member Functions

 OwnedChunk (Allocator &metadata_allocator, const SharedPtr< std::byte[]> &data)
 
 OwnedChunk (const OwnedChunk &)=delete
 
OwnedChunkoperator= (const OwnedChunk &)=delete
 
 OwnedChunk (OwnedChunk &&other)=default
 
OwnedChunkoperator= (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
 
Chunkoperator* ()
 
const Chunkoperator* () const
 
Chunkoperator-> ()
 
const Chunkoperator-> () 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< ChunkTake () &&
 

Friends

class Chunk
 

Member Function Documentation

◆ Release()

void pw::multibuf::v1_adapter::OwnedChunk::Release ( )
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.

◆ Take()

std::optional< Chunk > pw::multibuf::v1_adapter::OwnedChunk::Take ( ) &&
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*.


The documentation for this class was generated from the following file: