Struct dfqueue::DFQueueProducer
source · pub struct DFQueueProducer<T> { /* private fields */ }
Expand description
A producer that can enqueue elements into a DFQueue. Do not wrap this in an Arc or Mutex, the queue it is already protected by those on the interior.
Implementations§
source§impl<T> DFQueueProducer<T>
impl<T> DFQueueProducer<T>
sourcepub fn obtain_producer(&self) -> DFQueueProducer<T>
pub fn obtain_producer(&self) -> DFQueueProducer<T>
Call this to obtain another DFQueueProducer. DFQueueProducer does not implement the standard Clone trait, to avoid accidentally cloning it implicity.
sourcepub fn get_consumer(&self) -> Option<DFQueueConsumer<T>>
pub fn get_consumer(&self) -> Option<DFQueueConsumer<T>>
Returns a DFQueueConsumer for this queue, if it hasn’t yet been obtained
(either via this function or via DFQueue::into_consumer()
).
To ensure there is only a single DFQueueConsumer, it will return None
if there is already a DFQueueConsumer
.
sourcepub fn enqueue(&self, data: T) -> QueuedData<T>
pub fn enqueue(&self, data: T) -> QueuedData<T>
Pushes the given data
onto the queue.
Returns
Returns a QueuedData instance, an Arc-like reference to the given data
on the queue.
This ensures that the producer can still retain the given data
if the queue experiences a failure.