pub struct Consumer<T, const CAPACITY: usize, AllocT: Allocation<T>> { /* private fields */ }Expand description
The popping handle of an SPSC FIFO queue.
Created together with its paired Producer by
new (or new_hugepage_backed).
Consumer is Send but not Sync: at most one thread may pop at a
time.
Implementations§
Source§impl<T, const CAPACITY: usize, AllocT: Allocation<T>> Consumer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT: Allocation<T>> Consumer<T, CAPACITY, AllocT>
Sourcepub fn pop(&self) -> Option<T>
pub fn pop(&self) -> Option<T>
Pops the next item from the queue.
Wait-free. Returns Some(item) on success, None if the queue is
currently empty.
§Examples
use low_latency_data_structures::spsc::new;
let (producer, consumer) = new::<u64, 4>();
assert_eq!(consumer.pop(), None);
let _ = producer.push(42);
assert_eq!(consumer.pop(), Some(42));Trait Implementations§
Source§impl<T, const CAPACITY: usize, AllocT: Allocation<T>> Debug for Consumer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT: Allocation<T>> Debug for Consumer<T, CAPACITY, AllocT>
impl<T: Send, const CAPACITY: usize, AllocT: Allocation<T> + Send> Send for Consumer<T, CAPACITY, AllocT>
Auto Trait Implementations§
impl<T, const CAPACITY: usize, AllocT> !RefUnwindSafe for Consumer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT> !Sync for Consumer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT> !UnwindSafe for Consumer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT> Freeze for Consumer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT> Unpin for Consumer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT> UnsafeUnpin for Consumer<T, CAPACITY, AllocT>
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