pub struct DispatchQueue<T> { /* private fields */ }Expand description
Deterministic FIFO dispatch queue for attempt coordination.
§Invariants
- Intake is bounded to
capacity. - Dequeue order is deterministic FIFO.
- Shutdown state is explicit and inspectable.
- This type does not apply execution or retry policy.
Implementations§
Source§impl<T> DispatchQueue<T>
impl<T> DispatchQueue<T>
Sourcepub fn new(capacity: NonZeroUsize) -> Self
pub fn new(capacity: NonZeroUsize) -> Self
Creates a dispatch queue with bounded intake capacity.
Sourcepub fn enqueue(&mut self, item: T) -> Result<(), DispatchQueueError>
pub fn enqueue(&mut self, item: T) -> Result<(), DispatchQueueError>
Enqueues one work item.
Returns:
DispatchQueueError::Shutdownif the dispatch queue has been closed.DispatchQueueError::Backpressureif queue capacity is already reached.
Sourcepub fn dequeue(&mut self) -> Result<Option<T>, DispatchQueueError>
pub fn dequeue(&mut self) -> Result<Option<T>, DispatchQueueError>
Dequeues one work item in deterministic FIFO order.
Returns DispatchQueueError::Shutdown only when the dispatch queue has been shut down
and no queued work remains.
Sourcepub fn shutdown(&mut self)
pub fn shutdown(&mut self)
Marks the dispatch queue as shut down.
After shutdown:
- New intake is rejected.
- Existing queued items remain available to be drained in FIFO order.
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Returns true when dispatch queue has been marked shut down.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for DispatchQueue<T>
impl<T> RefUnwindSafe for DispatchQueue<T>where
T: RefUnwindSafe,
impl<T> Send for DispatchQueue<T>where
T: Send,
impl<T> Sync for DispatchQueue<T>where
T: Sync,
impl<T> Unpin for DispatchQueue<T>where
T: Unpin,
impl<T> UnsafeUnpin for DispatchQueue<T>
impl<T> UnwindSafe for DispatchQueue<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more