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>

source

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).

source

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.

source

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.

Trait Implementations§

source§

impl<T: Debug> Debug for QueuedData<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Deref for QueuedData<T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &T

Dereferences the value.

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for QueuedData<T>where T: RefUnwindSafe,

§

impl<T> Send for QueuedData<T>where T: Send + Sync,

§

impl<T> Sync for QueuedData<T>where T: Send + Sync,

§

impl<T> Unpin for QueuedData<T>

§

impl<T> UnwindSafe for QueuedData<T>where T: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.