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

Caching write end of some ring buffer.

Inserted items is not visible for an opposite write end until Self::commit/Self::sync is called or Self is dropped. A free space of items removed 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> RbWriteCache<T, R>where R::Rb: RbWrite<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 discard(&mut self)

Discard new items pushed since last sync.

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 RbWriteCache<T, R>where R::Rb: RbWrite<T>,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T, R: RbRef> RbBase<T> for RbWriteCache<T, R>where R::Rb: RbWrite<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> RbWrite<T> for RbWriteCache<T, R>where R::Rb: RbWrite<T>,

source§

unsafe fn set_tail(&self, value: usize)

Sets the new tail position. Read more
source§

unsafe fn advance_tail(&self, count: usize)

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

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

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

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

Provides a direct access to the ring buffer vacant memory. Returns a pair of slices of uninitialized memory, the second one may be empty. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

impl<T, R> UnwindSafe for RbWriteCache<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.