pub struct SpscConsumer<T, const CAP: usize> { /* private fields */ }Expand description
Consumer half of the lock-free SPSC ring buffer.
Implementations§
Source§impl<T, const CAP: usize> SpscConsumer<T, CAP>
impl<T, const CAP: usize> SpscConsumer<T, CAP>
Sourcepub fn pop(&self) -> Option<T>
pub fn pop(&self) -> Option<T>
Attempts to pop an item from the ring buffer.
Returns Some(item) if an element is available, or None if the buffer is empty.
Sourcepub fn drain_batch(&self, out: &mut Vec<T>, max: usize) -> usize
pub fn drain_batch(&self, out: &mut Vec<T>, max: usize) -> usize
Drains up to max items from the ring buffer into the provided out vector.
Returns the number of items drained.
Trait Implementations§
Source§impl<T, const CAP: usize> Debug for SpscConsumer<T, CAP>
impl<T, const CAP: usize> Debug for SpscConsumer<T, CAP>
Source§impl<T, const CAP: usize> Drop for SpscConsumer<T, CAP>
impl<T, const CAP: usize> Drop for SpscConsumer<T, CAP>
Auto Trait Implementations§
impl<T, const CAP: usize> !Freeze for SpscConsumer<T, CAP>
impl<T, const CAP: usize> !RefUnwindSafe for SpscConsumer<T, CAP>
impl<T, const CAP: usize> !Sync for SpscConsumer<T, CAP>
impl<T, const CAP: usize> !UnwindSafe for SpscConsumer<T, CAP>
impl<T, const CAP: usize> Send for SpscConsumer<T, CAP>
impl<T, const CAP: usize> Unpin for SpscConsumer<T, CAP>
impl<T, const CAP: usize> UnsafeUnpin for SpscConsumer<T, CAP>where
Arc<RingBuffer<T, CAP>>: 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