pub struct ItemQueue<T> { /* private fields */ }Expand description
See the module doc. Shared by reference between the lane threads.
Implementations§
Source§impl<T> ItemQueue<T>
impl<T> ItemQueue<T>
Sourcepub fn new(items: impl IntoIterator<Item = T>, lane_count: usize) -> Self
pub fn new(items: impl IntoIterator<Item = T>, lane_count: usize) -> Self
A queue of items for lanes 0..lane_count.
Sourcepub fn claim(&self, lane: usize) -> Option<ItemTicket<T>>
pub fn claim(&self, lane: usize) -> Option<ItemTicket<T>>
Claims the next item for lane, blocking while nothing is claimable for it but
another item is in flight. None means this lane is done for good (nothing it
can take is left, the lane was retired, or the queue was closed); items only it
could still have taken are then abandoned (see Self::take_abandoned).
Sourcepub fn complete(&self, ticket: ItemTicket<T>) -> T
pub fn complete(&self, ticket: ItemTicket<T>) -> T
The item was processed successfully; returns it.
Sourcepub fn fail(&self, lane: usize, ticket: ItemTicket<T>) -> FailOutcome<T>
pub fn fail(&self, lane: usize, ticket: ItemTicket<T>) -> FailOutcome<T>
lane failed the item: it goes back for a running lane that has not failed it,
or is abandoned when there is none.
Sourcepub fn retire(&self, lane: usize) -> Vec<T>
pub fn retire(&self, lane: usize) -> Vec<T>
Takes lane out of the rotation (it keeps failing, its worker went away) and
returns the items that no running lane can take any more.
Sourcepub fn take_abandoned(&self) -> Vec<T>
pub fn take_abandoned(&self) -> Vec<T>
Items abandoned when a lane exited from Self::claim (drained by this call).
Sourcepub fn close(&self) -> Vec<T>
pub fn close(&self) -> Vec<T>
Stops the queue (cancellation): every later Self::claim returns None, and
every item not yet claimed – plus any not yet taken with
Self::take_abandoned – is returned. Items in flight still come back through
Self::complete / Self::fail.
Sourcepub fn counts(&self) -> QueueCounts
pub fn counts(&self) -> QueueCounts
The queue’s current bookkeeping.