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

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.