class RingBufferReservation

Defined at line 114 of file ../../zircon/system/ulib/storage/buffer/include/storage/buffer/ring_buffer.h

A reservation of space within |RingBuffer|. Allows clients to safely access a portion

of the circular buffer for either reading or writing.

Releases the space when going out of scope (or reset).

This class is movable, but not copyable.

This class is thread-compatible.

Public Methods

void RingBufferReservation (internal::RingBufferState * buffer, size_t start, size_t length)

Creates a RingBufferReservation within a buffer, at |start| blocks within

the buffer, of |length| bytes long. [start, start + length) may wrap around the

RingBuffer.

Defined at line 104 of file ../../zircon/system/ulib/storage/buffer/ring_buffer.cc

void RingBufferReservation (RingBufferReservation && other)

Defined at line 108 of file ../../zircon/system/ulib/storage/buffer/ring_buffer.cc

RingBufferReservation & operator= (RingBufferReservation && other)

Defined at line 115 of file ../../zircon/system/ulib/storage/buffer/ring_buffer.cc

void RingBufferReservation ()

Defined at line 116 of file ../../zircon/system/ulib/storage/buffer/include/storage/buffer/ring_buffer.h

void RingBufferReservation (const RingBufferReservation & )

Defined at line 122 of file ../../zircon/system/ulib/storage/buffer/include/storage/buffer/ring_buffer.h

RingBufferReservation & operator= (const RingBufferReservation & )

Defined at line 123 of file ../../zircon/system/ulib/storage/buffer/include/storage/buffer/ring_buffer.h

void ~RingBufferReservation ()

Defined at line 128 of file ../../zircon/system/ulib/storage/buffer/ring_buffer.cc

zx::result<uint64_t> CopyRequests (cpp20::span<const storage::UnbufferedOperation> in_operations, size_t offset, std::vector<storage::BufferedOperation> * out_operations)

Copies from |in_requests|, at the provided |offset| into this reservation.

Updates the in-memory offsets of |requests| so they point to the correct offsets in the

in-memory buffer instead of their original VMOs, outputting these updated requests.

Returns an error if a VMO from |requests| cannot be accessed to write into

the buffer, but otherwise returns the number of blocks copied.

Preconditions:

- The reservation must be large enough to copy |requests|:

- offset + BlockCount(in_requests)

<

= length()

- |Reserved()| must be true.

Defined at line 139 of file ../../zircon/system/ulib/storage/buffer/ring_buffer.cc

BlockBufferView buffer_view ()

Defined at line 144 of file ../../zircon/system/ulib/storage/buffer/include/storage/buffer/ring_buffer.h

size_t start ()

The first reservation block, relative to the start of |RingBuffer|.

Defined at line 147 of file ../../zircon/system/ulib/storage/buffer/include/storage/buffer/ring_buffer.h

size_t length ()

The total length of this reservation, in blocks.

Defined at line 150 of file ../../zircon/system/ulib/storage/buffer/include/storage/buffer/ring_buffer.h

size_t capacity ()

The capacity of the underlying buffer.

Defined at line 153 of file ../../zircon/system/ulib/storage/buffer/include/storage/buffer/ring_buffer.h

vmoid_t vmoid ()

Defined at line 240 of file ../../zircon/system/ulib/storage/buffer/ring_buffer.cc

void * Data (size_t index)

Returns one block of data starting at block |index| within this reservation.

Since this data has been reserved, |RingBuffer| will not attempt to access it concurrently.

Preconditions:

- |Reserved()| must be true.

- |index|

<

|length()|

Defined at line 245 of file ../../zircon/system/ulib/storage/buffer/ring_buffer.cc

const void * Data (size_t index)

Defined at line 250 of file ../../zircon/system/ulib/storage/buffer/ring_buffer.cc

Protected Methods

bool Reserved ()

Returns true if the reservation holds blocks in a |RingBuffer|.

Defined at line 168 of file ../../zircon/system/ulib/storage/buffer/include/storage/buffer/ring_buffer.h

void Reset ()

Unreserves the reservation. This will cause |Reserved()| to return

false for the duration of the |RingBufferReservation|'s lifetime.

Defined at line 130 of file ../../zircon/system/ulib/storage/buffer/ring_buffer.cc