pub struct DetachedWorkIter<B: MutRB> { /* private fields */ }
Expand description

Same as WorkIter, but does not update the atomic index when advancing.

This makes it possible to explore available data back and forth, putting the consumer iterator on hold.

A typical use case of this structure is to search something amidst produced dataligning the detached iterator to a suitable indexnd then returning to a normal worker iterator.

This struct can only be created by detaching a worker iterator.

When done worker iterator can be re-obtained via Self::attach.

Note that, in order to avoid buffer saturationtomic index can be synced with Self::sync_index; this synchronises indices making the consumer iterator able to move on.

As WorkIter, this iterator returns mutable references to data stored within the buffer. Thuss stated in the docs written for the former, Self::advance has to be called when done with the mutation in order to move the iterator.

Implementations§

source§

impl<B: MutRB<Item = T>, T> DetachedWorkIter<B>

source

pub fn attach(self) -> WorkIter<B>

Attaches the iterator, yielding a WorkIter.

source

pub fn available(&mut self) -> usize

source

pub fn index(&self) -> usize

Same as WorkIter::index.

source

pub fn buf_len(&self) -> usize

source

pub unsafe fn set_index(&mut self, index: usize)

Sets local index.

§Safety

Index must always be between consumer and producer.

source

pub fn reset_index(&mut self)

Resets the local index of the iterator. I.e., moves the iterator to the location occupied by its successor. To sync with the atomic index, use Self::sync_index.

source

pub unsafe fn advance(&mut self, count: usize)

Advances the iterator as in WorkIter::available(), but does not modify the atomic counter, making the change local.

§Safety

See WorkIter::advance.

source

pub unsafe fn go_back(&mut self, count: usize)

Goes back, wrapping if necessary.

§Safety

Index must always be between consumer and producer.

source

pub fn is_prod_alive(&self) -> bool

source

pub fn is_cons_alive(&self) -> bool

source

pub fn get_workable(&mut self) -> Option<&mut T>

source

pub fn get_workable_slice_exact( &mut self, count: usize ) -> Option<WorkableSlice<'_, T>>

source

pub fn get_workable_slice_avail(&mut self) -> Option<WorkableSlice<'_, T>>

source

pub fn get_workable_slice_multiple_of( &mut self, rhs: usize ) -> Option<WorkableSlice<'_, T>>

source

pub fn sync_index(&self)

Synchronises the underlying atomic index with the local index. I.e. let the consumer iterator advance.

Trait Implementations§

source§

impl<B: ConcurrentRB + MutRB<Item = T>, T> Send for DetachedWorkIter<B>

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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 T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.