Struct FuturesOrdered

struct FuturesOrdered<T: Future> { ... }

An unbounded queue of futures.

This "combinator" is similar to FuturesUnordered, but it imposes a FIFO order on top of the set of futures. While futures in the set will race to completion in parallel, results will only be returned in the order their originating futures were added to the queue.

Futures are pushed into this queue and their realized values are yielded in order. This structure is optimized to manage a large number of futures. Futures managed by FuturesOrdered will only be polled when they generate notifications. This reduces the required amount of work needed to coordinate large numbers of futures.

When a FuturesOrdered is first created, it does not contain any futures. Calling poll_next in this state will result in Poll::Ready(None) to be returned. Futures are submitted to the queue using push_back (or push_front); however, the future will not be polled at this point. FuturesOrdered will only poll managed futures when FuturesOrdered::poll_next is called. As such, it is important to call poll_next after pushing new futures.

If FuturesOrdered::poll_next returns Poll::Ready(None) this means that the queue is currently not managing any futures. A future may be submitted to the queue at a later time. At that point, a call to FuturesOrdered::poll_next will either return the future's resolved value or Poll::Pending if the future has not yet completed. When multiple futures are submitted to the queue, FuturesOrdered::poll_next will return Poll::Pending until the first future completes, even if some of the later futures have already completed.

Note that you can create a ready-made FuturesOrdered via the collect method, or you can start with an empty queue with the FuturesOrdered::new constructor.

This type is only available when the std or alloc feature of this library is activated, and it is activated by default.

Implementations

impl<Fut: Future> FuturesOrdered<Fut>

fn new() -> Self

Constructs a new, empty FuturesOrdered

The returned FuturesOrdered does not contain any futures and, in this state, FuturesOrdered::poll_next will return Poll::Ready(None).

fn len(self: &Self) -> usize

Returns the number of futures contained in the queue.

This represents the total number of in-flight futures, both those currently processing and those that have completed but which are waiting for earlier futures to complete.

fn is_empty(self: &Self) -> bool

Returns true if the queue contains no futures

fn push(self: &mut Self, future: Fut)

Push a future into the queue.

This function submits the given future to the internal set for managing. This function will not call poll on the submitted future. The caller must ensure that FuturesOrdered::poll_next is called in order to receive task notifications.

fn push_back(self: &mut Self, future: Fut)

Pushes a future to the back of the queue.

This function submits the given future to the internal set for managing. This function will not call poll on the submitted future. The caller must ensure that FuturesOrdered::poll_next is called in order to receive task notifications.

fn push_front(self: &mut Self, future: Fut)

Pushes a future to the front of the queue.

This function submits the given future to the internal set for managing. This function will not call poll on the submitted future. The caller must ensure that FuturesOrdered::poll_next is called in order to receive task notifications. This future will be the next future to be returned complete.

impl<Fut: Future> Debug for FuturesOrdered<Fut>

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

impl<Fut: Future> Default for FuturesOrdered<Fut>

fn default() -> Self

impl<Fut: Future> Extend for FuturesOrdered<Fut>

fn extend<I>(self: &mut Self, iter: I)
where
    I: IntoIterator<Item = Fut>

impl<Fut: Future> FromIterator for FuturesOrdered<Fut>

fn from_iter<T>(iter: T) -> Self
where
    T: IntoIterator<Item = Fut>

impl<Fut: Future> FusedStream for FuturesOrdered<Fut>

fn is_terminated(self: &Self) -> bool

impl<Fut: Future> Stream for FuturesOrdered<Fut>

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<<Self as >::Item>>
fn size_hint(self: &Self) -> (usize, Option<usize>)

impl<S> TryStreamExt for FuturesOrdered<T>

impl<S, T, E> TryStream for FuturesOrdered<T>

fn try_poll_next(self: Pin<&mut S>, cx: &mut Context<'_>) -> Poll<Option<Result<<S as TryStream>::Ok, <S as TryStream>::Error>>>

impl<T> Any for FuturesOrdered<T>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for FuturesOrdered<T>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for FuturesOrdered<T>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> Freeze for FuturesOrdered<T>

impl<T> From for FuturesOrdered<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> RefUnwindSafe for FuturesOrdered<T>

impl<T> Send for FuturesOrdered<T>

impl<T> StreamExt for FuturesOrdered<T>

impl<T> Sync for FuturesOrdered<T>

impl<T> UnsafeUnpin for FuturesOrdered<T>

impl<T> UnwindSafe for FuturesOrdered<T>

impl<T, U> Into for FuturesOrdered<T>

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for FuturesOrdered<T>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for FuturesOrdered<T>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl<T: Future> Unpin for FuturesOrdered<T>