Pigweed
 
Loading...
Searching...
No Matches
pw::multibuf::OwnedChunk Class Reference

#include <chunk.h>

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 (OwnedChunk &&other) noexcept
 
OwnedChunkoperator= (OwnedChunk &&other) noexcept
 
 ~OwnedChunk ()
 This method will acquire a mutex and is not IRQ safe.
 
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
 
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
 
Chunkoperator* ()
 
const Chunkoperator* () const
 
Chunkoperator-> ()
 
const Chunkoperator-> () const
 
void Release ()
 
ChunkTake () &&
 

Friends

class Chunk
 
class ChunkRegionTracker
 
class MultiBuf
 
class MultiBufChunks
 

Detailed Description

An RAII handle to a contiguous slice of data.

Note: OwnedChunk may acquire a pw::sync::Mutex during destruction, and so must not be destroyed within ISR contexts.

Member Function Documentation

◆ Release()

void pw::multibuf::OwnedChunk::Release ( )

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

Chunk * pw::multibuf::OwnedChunk::Take ( ) &&
inline

Returns the contained Chunk* and empties this OwnedChunk without releasing the underlying Chunk.

Friends And Related Function Documentation

◆ Chunk

friend class Chunk
friend

Allow ChunkRegionTracker and MultiBuf to create OwnedChunks using the private constructor above.


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