Struct nolock::queues::mpsc::jiffy::Receiver [−][src]
pub struct Receiver<T> { /* fields omitted */ }
Expand description
The Single Receiver of a Jiffy-Queue, created by calling queue
Implementations
Checks if the Queue has been closed by the Producers
Note
Even when this method indicates that the Queue has been closed, there
may still be Elements left in the Queue and therefore you should
attempt to dequeue the next Element and only when you get back an Error
with DequeueError::Closed
can you be sure that there is nothing
left in the Queue and you can savely discard it.
Example:
let (mut rx, tx) = jiffy::queue::<usize>(); // The Producer side gets dropped and is therefore considered closed drop(tx); assert_eq!(true, rx.is_closed());
Attempts to dequeue the next entry in the Queue
Example
let (mut rx, tx) = jiffy::queue::<usize>(); // Insert one Element into the Queue tx.enqueue(13).unwrap(); // Retrieve the first and only Element from the Queue assert_eq!(Ok(13), rx.try_dequeue()); // Attempt to get the next Element, but there is none so we get // the right Error indicating that there is no Element to dequeue at // that moment assert_eq!(Err(DequeueError::WouldBlock), rx.try_dequeue());
This is a simple blocking dequeue. This is definetly not lock free anymore and will simply spin and try to dequeue an item over and over again.
Behaviour
This function will block until it either successfully dequeues an item
from the Queue and will then return Some(data)
or until the Queue has
been closed by the other Side, in which case it will return None
Returns a RefIter for the Queue, this allows you to still use the Queue-Receiver once the Iterator has been dropped
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Receiver<T>
impl<T> !UnwindSafe for Receiver<T>