pub struct RbReadCache<T, R: RbRef>where
    R::Rb: RbRead<T>,{ /* private fields */ }
Expand description

Caching read end of some ring buffer.

A free space of removed items is not visible for an opposite write end until Self::commit/Self::sync is called or Self is dropped. Items inserted by an opposite write end is not visible for Self until Self::sync is called.

Used to implement PostponedConsumer.

Implementations§

source§

impl<T, R: RbRef> RbReadCache<T, R>where R::Rb: RbRead<T>,

source

pub unsafe fn new(rb_ref: R) -> Self

Create new ring buffer cache.

Safety

There must be only one instance containing the same ring buffer reference.

source

pub fn commit(&mut self)

Commit changes to the ring buffer.

source

pub fn sync(&mut self)

Commit changes and fetch updates from the ring buffer.

source

pub fn release(self) -> R

Commit and destroy Self returning underlying ring buffer.

Trait Implementations§

source§

impl<T, R: RbRef> Drop for RbReadCache<T, R>where R::Rb: RbRead<T>,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T, R: RbRef> RbBase<T> for RbReadCache<T, R>where R::Rb: RbRead<T>,

source§

unsafe fn slices( &self, head: usize, tail: usize ) -> (&mut [MaybeUninit<T>], &mut [MaybeUninit<T>])

Returns part of underlying raw ring buffer memory as slices. Read more
source§

fn capacity_nonzero(&self) -> NonZeroUsize

Capacity of the ring buffer. Read more
source§

fn head(&self) -> usize

Head position.
source§

fn tail(&self) -> usize

Tail position.
source§

fn modulus(&self) -> NonZeroUsize

Modulus for head and tail values. Read more
source§

fn occupied_len(&self) -> usize

The number of items stored in the buffer at the moment.
source§

fn vacant_len(&self) -> usize

The number of vacant places in the buffer at the moment.
source§

fn is_empty(&self) -> bool

Checks if the occupied range is empty.
source§

fn is_full(&self) -> bool

Checks if the vacant range is empty.
source§

impl<T, R: RbRef> RbRead<T> for RbReadCache<T, R>where R::Rb: RbRead<T>,

source§

unsafe fn set_head(&self, value: usize)

Sets the new head position. Read more
source§

unsafe fn advance_head(&self, count: usize)

Move head position by count items forward. Read more
source§

fn occupied_ranges(&self) -> (Range<usize>, Range<usize>)

Returns a pair of ranges of Self::occupied_slices location in underlying container.
source§

unsafe fn occupied_slices( &self ) -> (&mut [MaybeUninit<T>], &mut [MaybeUninit<T>])

Provides a direct mutable access to the ring buffer occupied memory. Read more
source§

unsafe fn skip_internal(&self, count_or_all: Option<usize>) -> usize

Removes items from the head of ring buffer and drops them. Read more

Auto Trait Implementations§

§

impl<T, R> !RefUnwindSafe for RbReadCache<T, R>

§

impl<T, R> Send for RbReadCache<T, R>where R: Send, T: Send,

§

impl<T, R> !Sync for RbReadCache<T, R>

§

impl<T, R> Unpin for RbReadCache<T, R>where R: Unpin, T: Unpin,

§

impl<T, R> UnwindSafe for RbReadCache<T, R>where R: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.