Struct futures::stream::FuturesUnordered [−][src]
#[must_use = "streams do nothing unless polled"]pub struct FuturesUnordered<F> { /* fields omitted */ }
A set of Future
s which may complete in any order.
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
poll large numbers of futures.
FuturesUnordered
can be filled by collect
ing an iterator of Future
s
into a FuturesUnordered
, or by push
ing Future
s onto an existing
FuturesUnordered
. When new Future
s are added, poll_next
must be
called in order to begin receiving wakeups for new Future
s.
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.
Methods
impl<T> FuturesUnordered<T> where
T: Future,
[src]
impl<T> FuturesUnordered<T> where
T: Future,
pub fn new() -> FuturesUnordered<T>
[src]
pub fn new() -> FuturesUnordered<T>
Constructs a new, empty FuturesUnordered
The returned FuturesUnordered
does not contain any futures and, in this
state, FuturesUnordered::poll_next
will return Ok(Async::Ready(None))
.
impl<T> FuturesUnordered<T>
[src]
impl<T> FuturesUnordered<T>
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Returns the number of futures contained in the set.
This represents the total number of in-flight futures.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Returns true
if the set contains no futures
pub fn push(&mut self, future: T)
[src]
pub fn push(&mut self, future: T)
Push a future into the set.
This function submits the given future to the set for managing. This
function will not call poll
on the submitted future. The caller must
ensure that FuturesUnordered::poll_next
is called in order to receive task
notifications.
pub fn iter_mut(&mut self) -> IterMut<T>
[src]
pub fn iter_mut(&mut self) -> IterMut<T>
Returns an iterator that allows modifying each future in the set.
Trait Implementations
impl<T> Debug for FuturesUnordered<T> where
T: Debug,
[src]
impl<T> Debug for FuturesUnordered<T> where
T: Debug,
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl<T> Drop for FuturesUnordered<T>
[src]
impl<T> Drop for FuturesUnordered<T>
impl<T> Sync for FuturesUnordered<T> where
T: Sync,
[src]
impl<T> Sync for FuturesUnordered<T> where
T: Sync,
impl<F> FromIterator<F> for FuturesUnordered<F> where
F: Future,
[src]
impl<F> FromIterator<F> for FuturesUnordered<F> where
F: Future,
fn from_iter<T>(iter: T) -> FuturesUnordered<F> where
T: IntoIterator<Item = F>,
[src]
fn from_iter<T>(iter: T) -> FuturesUnordered<F> where
T: IntoIterator<Item = F>,
Creates a value from an iterator. Read more
impl<T> Send for FuturesUnordered<T> where
T: Send,
[src]
impl<T> Send for FuturesUnordered<T> where
T: Send,
impl<T> Stream for FuturesUnordered<T> where
T: Future,
[src]
impl<T> Stream for FuturesUnordered<T> where
T: Future,
type Item = <T as Future>::Item
Values yielded by the stream.
type Error = <T as Future>::Error
Errors yielded by the stream.
fn poll_next(
&mut self,
cx: &mut Context
) -> Result<Async<Option<<T as Future>::Item>>, <T as Future>::Error>
[src]
fn poll_next(
&mut self,
cx: &mut Context
) -> Result<Async<Option<<T as Future>::Item>>, <T as Future>::Error>
Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None
if the stream is exhausted. Read more