pub struct FuturesOrdered<T>where
T: Future,{ /* private fields */ }
Expand description
An unbounded queue of futures.
This “combinator” is similar to FuturesUnordered
, but it imposes an 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
in this state will result in Ok(Async::Ready(None))
to be
returned. Futures are submitted to the queue using push
; however, the
future will not be polled at this point. FuturesOrdered
will only
poll managed futures when FuturesOrdered::poll
is called. As such, it
is important to call poll
after pushing new futures.
If FuturesOrdered::poll
returns Ok(Async::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
will either return the future’s resolved value
or Ok(Async::Pending)
if the future has not yet completed. When
multiple futures are submitted to the queue, FuturesOrdered::poll
will
return Ok(Async::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
futures_ordered
function in the stream
module, or you can start with an
empty queue with the FuturesOrdered::new
constructor.
Implementations§
Source§impl<T> FuturesOrdered<T>where
T: Future,
impl<T> FuturesOrdered<T>where
T: Future,
Sourcepub fn new() -> FuturesOrdered<T>
pub fn new() -> FuturesOrdered<T>
Constructs a new, empty FuturesOrdered
The returned FuturesOrdered
does not contain any futures and, in this
state, FuturesOrdered::poll
will return Ok(Async::Ready(None))
.
Trait Implementations§
Source§impl<T> Debug for FuturesOrdered<T>
impl<T> Debug for FuturesOrdered<T>
Source§impl<F> FromIterator<F> for FuturesOrdered<F>where
F: Future,
impl<F> FromIterator<F> for FuturesOrdered<F>where
F: Future,
Source§fn from_iter<T>(iter: T) -> FuturesOrdered<F>where
T: IntoIterator<Item = F>,
fn from_iter<T>(iter: T) -> FuturesOrdered<F>where
T: IntoIterator<Item = F>,
Source§impl<T> Stream for FuturesOrdered<T>where
T: Future,
impl<T> Stream for FuturesOrdered<T>where
T: Future,
Source§fn poll_next(
&mut self,
cx: &mut Context<'_>,
) -> Result<Async<Option<<FuturesOrdered<T> as Stream>::Item>>, <FuturesOrdered<T> as Stream>::Error>
fn poll_next( &mut self, cx: &mut Context<'_>, ) -> Result<Async<Option<<FuturesOrdered<T> as Stream>::Item>>, <FuturesOrdered<T> as Stream>::Error>
None
if the stream is exhausted. Read moreAuto Trait Implementations§
impl<T> Freeze for FuturesOrdered<T>
impl<T> !RefUnwindSafe for FuturesOrdered<T>
impl<T> Send for FuturesOrdered<T>
impl<T> Sync for FuturesOrdered<T>
impl<T> Unpin for FuturesOrdered<T>
impl<T> !UnwindSafe for FuturesOrdered<T>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> StreamExt for T
impl<T> StreamExt for T
Source§fn next(self) -> StreamFuture<Self>where
Self: Sized,
fn next(self) -> StreamFuture<Self>where
Self: Sized,
Future
. Read moreSource§fn filter<R, P>(self, pred: P) -> Filter<Self, R, P>
fn filter<R, P>(self, pred: P) -> Filter<Self, R, P>
Source§fn filter_map<R, B, F>(self, f: F) -> FilterMap<Self, R, F>
fn filter_map<R, B, F>(self, f: F) -> FilterMap<Self, R, F>
Source§fn then<U, F>(self, f: F) -> Then<Self, U, F>
fn then<U, F>(self, f: F) -> Then<Self, U, F>
f
. Read moreSource§fn and_then<U, F>(self, f: F) -> AndThen<Self, U, F>
fn and_then<U, F>(self, f: F) -> AndThen<Self, U, F>
f
. Read moreSource§fn or_else<U, F>(self, f: F) -> OrElse<Self, U, F>
fn or_else<U, F>(self, f: F) -> OrElse<Self, U, F>
f
. Read moreSource§fn collect<C>(self) -> Collect<Self, C>
fn collect<C>(self) -> Collect<Self, C>
Source§fn concat(self) -> Concat<Self>
fn concat(self) -> Concat<Self>
Source§fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>
fn fold<T, Fut, F>(self, init: T, f: F) -> Fold<Self, Fut, T, F>
Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn skip_while<R, P>(self, pred: P) -> SkipWhile<Self, R, P>
fn skip_while<R, P>(self, pred: P) -> SkipWhile<Self, R, P>
true
. Read moreSource§fn take_while<R, P>(self, pred: P) -> TakeWhile<Self, R, P>
fn take_while<R, P>(self, pred: P) -> TakeWhile<Self, R, P>
true
. Read moreSource§fn for_each<U, F>(self, f: F) -> ForEach<Self, U, F>
fn for_each<U, F>(self, f: F) -> ForEach<Self, U, F>
Source§fn for_each_concurrent<U, F>(self, f: F) -> ForEachConcurrent<Self, U, F>
fn for_each_concurrent<U, F>(self, f: F) -> ForEachConcurrent<Self, U, F>
for_each
but may begin
processing an element while previous elements are still being processed. Read moreSource§fn err_into<E>(self) -> ErrInto<Self, E>
fn err_into<E>(self) -> ErrInto<Self, E>
Into
trait. Read moreSource§fn take(self, amt: u64) -> Take<Self>where
Self: Sized,
fn take(self, amt: u64) -> Take<Self>where
Self: Sized,
amt
items of the underlying stream. Read moreSource§fn skip(self, amt: u64) -> Skip<Self>where
Self: Sized,
fn skip(self, amt: u64) -> Skip<Self>where
Self: Sized,
amt
items of the underlying stream. Read moreSource§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
finished. Read moreSource§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Source§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
Source§fn buffered(self, amt: usize) -> Buffered<Self>
fn buffered(self, amt: usize) -> Buffered<Self>
Source§fn buffer_unordered(self, amt: usize) -> BufferUnordered<Self>
fn buffer_unordered(self, amt: usize) -> BufferUnordered<Self>
Source§fn zip<S>(self, other: S) -> Zip<Self, S>
fn zip<S>(self, other: S) -> Zip<Self, S>
Source§fn peekable(self) -> Peekable<Self>where
Self: Sized,
fn peekable(self) -> Peekable<Self>where
Self: Sized,
peek
method. Read moreSource§fn chunks(self, capacity: usize) -> Chunks<Self>where
Self: Sized,
fn chunks(self, capacity: usize) -> Chunks<Self>where
Self: Sized,
Source§fn select<S>(self, other: S) -> Select<Self, S>
fn select<S>(self, other: S) -> Select<Self, S>
Source§fn forward<S>(self, sink: S) -> Forward<Self, S>
fn forward<S>(self, sink: S) -> Forward<Self, S>
Source§fn split(self) -> (SplitSink<Self>, SplitStream<Self>)
fn split(self) -> (SplitSink<Self>, SplitStream<Self>)
Source§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Source§fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
fn inspect_err<F>(self, f: F) -> InspectErr<Self, F>
Source§fn recover<E, F>(self, f: F) -> Recover<Self, E, F>
fn recover<E, F>(self, f: F) -> Recover<Self, E, F>
Option<Self::Item>
, such that a None
value terminates the stream. Read more