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>
impl<B: MutRB<Item = T>, T> DetachedWorkIter<B>
sourcepub fn available(&mut self) -> usize
pub fn available(&mut self) -> usize
Same as WorkIter::available
.
sourcepub fn index(&self) -> usize
pub fn index(&self) -> usize
Same as WorkIter::index
.
sourcepub fn buf_len(&self) -> usize
pub fn buf_len(&self) -> usize
Same as WorkIter::buf_len
.
sourcepub fn reset_index(&mut self)
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
.
sourcepub unsafe fn advance(&mut self, count: usize)
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
.
sourcepub fn is_prod_alive(&self) -> bool
pub fn is_prod_alive(&self) -> bool
Same as WorkIter::is_prod_alive
.
sourcepub fn is_cons_alive(&self) -> bool
pub fn is_cons_alive(&self) -> bool
Same as WorkIter::is_cons_alive
.
sourcepub fn get_workable(&mut self) -> Option<&mut T>
pub fn get_workable(&mut self) -> Option<&mut T>
Same as WorkIter::get_workable
.
sourcepub fn get_workable_slice_exact(
&mut self,
count: usize
) -> Option<WorkableSlice<'_, T>>
pub fn get_workable_slice_exact( &mut self, count: usize ) -> Option<WorkableSlice<'_, T>>
Same as WorkIter::get_workable_slice_exact
.
sourcepub fn get_workable_slice_avail(&mut self) -> Option<WorkableSlice<'_, T>>
pub fn get_workable_slice_avail(&mut self) -> Option<WorkableSlice<'_, T>>
Same as WorkIter::get_workable_slice_avail
.
sourcepub fn get_workable_slice_multiple_of(
&mut self,
rhs: usize
) -> Option<WorkableSlice<'_, T>>
pub fn get_workable_slice_multiple_of( &mut self, rhs: usize ) -> Option<WorkableSlice<'_, T>>
sourcepub fn sync_index(&self)
pub fn sync_index(&self)
Synchronises the underlying atomic index with the local index. I.e. let the consumer iterator advance.