pub struct Producer<T, const CAPACITY: usize, AllocT: Allocation<T>> { /* private fields */ }Expand description
The pushing handle of an SPSC FIFO queue.
Created together with its paired Consumer by
new (or new_hugepage_backed).
Producer is Send but not Sync: at most one thread may push at a
time.
Implementations§
Source§impl<T, const CAPACITY: usize, AllocT: Allocation<T>> Producer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT: Allocation<T>> Producer<T, CAPACITY, AllocT>
Sourcepub fn push(&self, item: T) -> Option<T>
pub fn push(&self, item: T) -> Option<T>
Pushes item onto the queue.
Wait-free. Never blocks, never allocates. Returns None on success.
If the queue is full the item is returned unchanged as Some(item),
so the caller can retry or back off without losing data.
§Examples
use low_latency_data_structures::spsc::new;
let (producer, consumer) = new::<u64, 2>();
assert_eq!(producer.push(1), None);
assert_eq!(producer.push(2), None);
// Queue is full; item is handed back so we can retry later.
assert_eq!(producer.push(3), Some(3));Trait Implementations§
Source§impl<T, const CAPACITY: usize, AllocT: Allocation<T>> Debug for Producer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT: Allocation<T>> Debug for Producer<T, CAPACITY, AllocT>
impl<T: Send, const CAPACITY: usize, AllocT: Allocation<T> + Send> Send for Producer<T, CAPACITY, AllocT>
Auto Trait Implementations§
impl<T, const CAPACITY: usize, AllocT> !RefUnwindSafe for Producer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT> !Sync for Producer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT> !UnwindSafe for Producer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT> Freeze for Producer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT> Unpin for Producer<T, CAPACITY, AllocT>
impl<T, const CAPACITY: usize, AllocT> UnsafeUnpin for Producer<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