Struct dfqueue::QueuedData
source · pub struct QueuedData<T>(/* private fields */);
Expand description
A special reference type that wraps a data item that has been queued. This is returned to a producer thread (the user of a DFQueueProducer) when enqueuing an item onto the queue so that the producer can retain a reference to it in the case of failure.
Implementations§
source§impl<T> QueuedData<T>
impl<T> QueuedData<T>
sourcepub fn is_completed(&self) -> bool
pub fn is_completed(&self) -> bool
Whether this item has been completed (handled) by the DFQueueConsumer. If an item is completed, it’s okay to remove it from the queue (and it will be removed).
sourcepub fn is_enqueued(&self) -> bool
pub fn is_enqueued(&self) -> bool
Returns true if this data is still on the queue
The logic here is as follows: the thread invoking this function holds one reference. Thus, if there is more than one reference, then it means it is on the queue, because the queue also holds a reference to it. That’s why we cannot call it internally – it won’t be correct because the original producer thread may also be holding a reference to it, in order for that producer to retain a reference to it.
Private note: do not call this internally! This is a public API meant for the producer thread to use.
sourcepub fn has_failed(&self) -> bool
pub fn has_failed(&self) -> bool
The logic here is as follows: if the item on the queue has only one reference, and has not been completed, that means it is no longer on the queue (the consumer thread crashed or failed). Again, the producer thread invoking this function holds one reference, and if the data is indeed enqueued, that constitutes another reference. If the reference held in the queue isn’t there (only one total), and the thread hasn’t completed (it may have just been completed in another enqueue call), then something went wrong because it’s not complete and not on the queue anymore.
Private note: do not call this internally! This is a public API meant for the producer thread to use.