Struct st3::fifo::Stealer

source ·
#[repr(transparent)]
pub struct Stealer<T> { /* private fields */ }
Expand description

Handle for multi-threaded stealing operations.

Implementations§

Attempts to steal items from the head of the queue and move them to the tail of another queue.

Up to N items are moved to the destination queue, where N is specified by a closure which takes as argument the total count of items available for stealing. Upon success, the number of items ultimately transferred to the destination queue can be from 1 to N, depending on the number of available items and the capacity of the destination queue; the count of transferred items is returned as the success payload.

Errors

An error is returned in the following cases:

  1. no item was stolen, either because the queue is empty, the destination is full or N is 0,
  2. a concurrent stealing operation is ongoing.

Attempts to steal items from the head of the queue, returning one of them directly and moving the others to the tail of another queue.

Up to N items are stolen (including the one returned directly), where N is specified by a closure which takes as argument the total count of items available for stealing. Upon success, one item is returned and from 0 to N-1 items are moved to the destination queue, depending on the number of available items and the capacity of the destination queue; the number of transferred items is returned as the second field of the success value.

The returned item is the most recent one among the stolen items.

Errors

An error is returned in the following cases:

  1. no item was stolen, either because the queue is empty or N is 0,
  2. a concurrent stealing operation is ongoing.

Failure to transfer any item to the destination queue is not considered an error as long as one element could be returned directly. This can occur if the destination queue is full, if the source queue has only one item or if N is 1.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.