pub struct Producer<T, const CAPACITY: usize, A>where
A: Allocator,{ /* private fields */ }Expand description
Implementations§
Source§impl<T, const CAPACITY: usize, A> Producer<T, CAPACITY, A>where
A: Allocator,
impl<T, const CAPACITY: usize, A> Producer<T, CAPACITY, A>where
A: Allocator,
Sourcepub fn push(&mut self, item: T) -> Option<T>
pub fn push(&mut 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::{self, new};
use low_latency_data_structures::mem::global::GlobalAllocator;
let (mut producer, mut consumer) = new::<u64, 2, GlobalAllocator>(
spsc::Options::global_mlocked(),
);
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§
impl<T, const CAPACITY: usize, A> Send for Producer<T, CAPACITY, A>
Auto Trait Implementations§
impl<T, const CAPACITY: usize, A> !RefUnwindSafe for Producer<T, CAPACITY, A>
impl<T, const CAPACITY: usize, A> !Sync for Producer<T, CAPACITY, A>
impl<T, const CAPACITY: usize, A> !UnwindSafe for Producer<T, CAPACITY, A>
impl<T, const CAPACITY: usize, A> Freeze for Producer<T, CAPACITY, A>
impl<T, const CAPACITY: usize, A> Unpin for Producer<T, CAPACITY, A>
impl<T, const CAPACITY: usize, A> UnsafeUnpin for Producer<T, CAPACITY, A>
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