pub struct Drainer<'ring, T> { /* private fields */ }Expand description
Batch-drain handle for a Ring<T>. The ring is multi-consumer, so any
number of Drainers (or bare Ring::dequeue callers) may drain the same
ring concurrently while producers push — each pop is CAS-linearised on
dequeue_pos.
Implementations§
Source§impl<'ring, T> Drainer<'ring, T>
impl<'ring, T> Drainer<'ring, T>
Sourcepub fn drain_into(&mut self, out: &mut [T]) -> usize
pub fn drain_into(&mut self, out: &mut [T]) -> usize
Move up to out.len() items out of the ring into out in FIFO order.
Returns the number of items written. Each item is claimed via the
multi-consumer Ring::dequeue CAS, so concurrent drainers split the
stream without ever reading the same cell; the loop stops at the first
empty pop (another consumer may have raced us to the tail).
Auto Trait Implementations§
impl<'ring, T> !RefUnwindSafe for Drainer<'ring, T>
impl<'ring, T> !UnwindSafe for Drainer<'ring, T>
impl<'ring, T> Freeze for Drainer<'ring, T>
impl<'ring, T> Send for Drainer<'ring, T>
impl<'ring, T> Sync for Drainer<'ring, T>
impl<'ring, T> Unpin for Drainer<'ring, T>
impl<'ring, T> UnsafeUnpin for Drainer<'ring, T>where
&'ring Ring<T>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more