pub struct FuturesUnordered<F> { /* private fields */ }Expand description
An unbounded set of futures.
This “combinator” also serves a special function in this library, providing the ability to maintain a set of futures that and manage driving them all to completion.
Futures are pushed into this set and their realized values are yielded as
they are ready. This structure is optimized to manage a large number of
futures. Futures managed by FuturesUnordered will only be polled when they
generate notifications. This reduces the required amount of work needed to
coordinate large numbers of futures.
When a FuturesUnordered 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 set using push; however, the
future will not be polled at this point. FuturesUnordered will only
poll managed futures when FuturesUnordered::poll is called. As such, it
is important to call poll after pushing new futures.
If FuturesUnordered::poll returns Ok(Async::Ready(None)) this means that
the set is currently not managing any futures. A future may be submitted
to the set at a later time. At that point, a call to
FuturesUnordered::poll will either return the future’s resolved value
or Ok(Async::NotReady) if the future has not yet completed.
Note that you can create a ready-made FuturesUnordered via the
futures_unordered function in the stream module, or you can start with an
empty set with the FuturesUnordered::new constructor.
Implementations§
Source§impl<T> FuturesUnordered<T>where
T: Future,
impl<T> FuturesUnordered<T>where
T: Future,
Sourcepub fn new() -> FuturesUnordered<T>
pub fn new() -> FuturesUnordered<T>
Constructs a new, empty FuturesUnordered
The returned FuturesUnordered does not contain any futures and, in this
state, FuturesUnordered::poll will return Ok(Async::Ready(None)).
Source§impl<T> FuturesUnordered<T>
impl<T> FuturesUnordered<T>
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of futures contained in the set.
This represents the total number of in-flight futures.
Trait Implementations§
Source§impl<T> Debug for FuturesUnordered<T>where
T: Debug,
impl<T> Debug for FuturesUnordered<T>where
T: Debug,
Source§impl<T> Default for FuturesUnordered<T>where
T: Future,
impl<T> Default for FuturesUnordered<T>where
T: Future,
Source§fn default() -> FuturesUnordered<T>
fn default() -> FuturesUnordered<T>
Source§impl<T> Drop for FuturesUnordered<T>
impl<T> Drop for FuturesUnordered<T>
Source§impl<F> FromIterator<F> for FuturesUnordered<F>where
F: Future,
impl<F> FromIterator<F> for FuturesUnordered<F>where
F: Future,
Source§fn from_iter<T>(iter: T) -> FuturesUnordered<F>where
T: IntoIterator<Item = F>,
fn from_iter<T>(iter: T) -> FuturesUnordered<F>where
T: IntoIterator<Item = F>,
Source§impl<T> Stream for FuturesUnordered<T>where
T: Future,
impl<T> Stream for FuturesUnordered<T>where
T: Future,
Source§fn poll(
&mut self,
) -> Result<Async<Option<<T as Future>::Item>>, <T as Future>::Error>
fn poll( &mut self, ) -> Result<Async<Option<<T as Future>::Item>>, <T as Future>::Error>
None if
the stream is finished. Read moreSource§fn wait(self) -> Wait<Self> ⓘwhere
Self: Sized,
fn wait(self) -> Wait<Self> ⓘwhere
Self: Sized,
Source§fn into_future(self) -> StreamFuture<Self>where
Self: Sized,
fn into_future(self) -> StreamFuture<Self>where
Self: Sized,
Future. Read moreSource§fn filter<F>(self, f: F) -> Filter<Self, F>
fn filter<F>(self, f: F) -> Filter<Self, F>
Source§fn filter_map<F, B>(self, f: F) -> FilterMap<Self, F>
fn filter_map<F, B>(self, f: F) -> FilterMap<Self, F>
Source§fn then<F, U>(self, f: F) -> Then<Self, F, U>
fn then<F, U>(self, f: F) -> Then<Self, F, U>
f. Read moreSource§fn and_then<F, U>(self, f: F) -> AndThen<Self, F, U>
fn and_then<F, U>(self, f: F) -> AndThen<Self, F, U>
f. Read moreSource§fn or_else<F, U>(self, f: F) -> OrElse<Self, F, U>
fn or_else<F, U>(self, f: F) -> OrElse<Self, F, U>
f. Read moreSource§fn collect(self) -> Collect<Self>where
Self: Sized,
fn collect(self) -> Collect<Self>where
Self: Sized,
Source§fn concat2(self) -> Concat2<Self>
fn concat2(self) -> Concat2<Self>
Source§fn concat(self) -> Concat<Self>
fn concat(self) -> Concat<Self>
Stream::concat2 insteadSource§fn fold<F, T, Fut>(self, init: T, f: F) -> Fold<Self, F, Fut, T>where
F: FnMut(T, Self::Item) -> Fut,
Fut: IntoFuture<Item = T>,
Self::Error: From<<Fut as IntoFuture>::Error>,
Self: Sized,
fn fold<F, T, Fut>(self, init: T, f: F) -> Fold<Self, F, Fut, T>where
F: FnMut(T, Self::Item) -> Fut,
Fut: IntoFuture<Item = T>,
Self::Error: From<<Fut as IntoFuture>::Error>,
Self: Sized,
Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn skip_while<P, R>(self, pred: P) -> SkipWhile<Self, P, R>
fn skip_while<P, R>(self, pred: P) -> SkipWhile<Self, P, R>
true. Read moreSource§fn take_while<P, R>(self, pred: P) -> TakeWhile<Self, P, R>
fn take_while<P, R>(self, pred: P) -> TakeWhile<Self, P, R>
true. Read moreSource§fn for_each<F, U>(self, f: F) -> ForEach<Self, F, U>
fn for_each<F, U>(self, f: F) -> ForEach<Self, F, U>
Source§fn from_err<E>(self) -> FromErr<Self, E>
fn from_err<E>(self) -> FromErr<Self, E>
From for
this stream’s Error, returning a new stream. 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 merge<S>(self, other: S) -> Merge<Self, S>
fn merge<S>(self, other: S) -> Merge<Self, S>
select nowSource§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 more