pub struct Consumer<T> { /* private fields */ }Expand description
The consumer half of an SPSC ring buffer.
Use pop to remove elements. Takes &mut self to
statically ensure single-consumer access.
Implementations§
Source§impl<T> Consumer<T>
impl<T> Consumer<T>
Sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Attempts to pop a value from the ring buffer.
Returns Some(value) if data is available, None if the buffer is empty.
Values are returned in FIFO order.
§Example
use nexus_queue;
let (mut producer, mut consumer) = nexus_queue::ring_buffer::<u32>(8);
assert_eq!(consumer.pop(), None); // Empty
producer.push(42).unwrap();
assert_eq!(consumer.pop(), Some(42));Sourcepub fn is_disconnected(&self) -> bool
pub fn is_disconnected(&self) -> bool
Returns true if the producer has been dropped.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Consumer<T>
impl<T> !RefUnwindSafe for Consumer<T>
impl<T> !Sync for Consumer<T>
impl<T> Unpin for Consumer<T>
impl<T> !UnwindSafe for Consumer<T>
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