Skip to main content

ItemQueue

Struct ItemQueue 

Source
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>

Source

pub fn new(items: impl IntoIterator<Item = T>, lane_count: usize) -> Self

A queue of items for lanes 0..lane_count.

Source

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

Source

pub fn complete(&self, ticket: ItemTicket<T>) -> T

The item was processed successfully; returns it.

Source

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.

Source

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.

Source

pub fn take_abandoned(&self) -> Vec<T>

Items abandoned when a lane exited from Self::claim (drained by this call).

Source

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.

Source

pub fn counts(&self) -> QueueCounts

The queue’s current bookkeeping.

Trait Implementations§

Source§

impl<T: Debug> Debug for ItemQueue<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for ItemQueue<T>

§

impl<T> RefUnwindSafe for ItemQueue<T>
where Mutex<QueueState<T>>: RefUnwindSafe,

§

impl<T> Send for ItemQueue<T>
where Mutex<QueueState<T>>: Send,

§

impl<T> Sync for ItemQueue<T>
where Mutex<QueueState<T>>: Sync,

§

impl<T> Unpin for ItemQueue<T>
where Mutex<QueueState<T>>: Unpin,

§

impl<T> UnsafeUnpin for ItemQueue<T>
where Mutex<QueueState<T>>: UnsafeUnpin,

§

impl<T> UnwindSafe for ItemQueue<T>
where Mutex<QueueState<T>>: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more