pub struct Receiver<T>(_);
Expand description
The receiving Half for a SCQ based MPMC-Queue
Implementations
sourceimpl<T> Receiver<T>
impl<T> Receiver<T>
sourcepub fn try_dequeue(&self) -> Result<T, DequeueError>
pub fn try_dequeue(&self) -> Result<T, DequeueError>
Attempts to Dequeue an item from the Queue
Example
Successfully enqueue Element
let (rx, tx) = scq::queue::<u64>(10);
// Enqueue an Item
tx.try_enqueue(13).unwrap();
// Dequeue the Item
assert_eq!(Ok(13), rx.try_dequeue());
Enqueue from empty Queue
let (rx, tx) = scq::queue::<u64>(10);
// Attempt to Dequeue an item
assert_eq!(Err(DequeueError::Empty), rx.try_dequeue());
sourcepub fn is_closed(&self) -> bool
pub fn is_closed(&self) -> bool
Checks if the Sending Half has closed the Queue, meaning that no more new Elements will be added to the Queue.
Note
Even if this indicates that the Queue has been closed, by the Sender and no more new Elements will be inserted into the Queue, there might still be Elements left in the Queue that are waiting to be dequeued.
Example
let (rx, tx) = scq::queue::<u64>(10);
assert_eq!(false, rx.is_closed());
tx.try_enqueue(13).unwrap();
drop(tx);
assert_eq!(true, rx.is_closed());
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Receiver<T>
impl<T> Send for Receiver<T>where
T: Send,
impl<T> Sync for Receiver<T>
impl<T> Unpin for Receiver<T>
impl<T> !UnwindSafe for Receiver<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more