Struct futures::stream::FuturesUnordered [−][src]
#[must_use = "streams do nothing unless polled"]pub struct FuturesUnordered<Fut> { /* 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<Fut> FuturesUnordered<Fut> where
Fut: Future,
[src]
impl<Fut> FuturesUnordered<Fut> where
Fut: Future,
pub fn new() -> FuturesUnordered<Fut>
[src]
pub fn new() -> FuturesUnordered<Fut>
Constructs a new, empty FuturesUnordered
The returned FuturesUnordered
does not contain any futures.
In this state, FuturesUnordered::poll_next
will return
Poll::Ready(None)
.
impl<Fut> FuturesUnordered<Fut>
[src]
impl<Fut> FuturesUnordered<Fut>
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: Fut)
[src]
pub fn push(&mut self, future: Fut)
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<Fut> where
Fut: Unpin,
[src]
pub fn iter_mut(&mut self) -> IterMut<Fut> where
Fut: Unpin,
Returns an iterator that allows modifying each future in the set.
pub fn iter_pin_mut(
self: PinMut<'a, FuturesUnordered<Fut>>
) -> IterPinMut<'a, Fut>
[src]
pub fn iter_pin_mut(
self: PinMut<'a, FuturesUnordered<Fut>>
) -> IterPinMut<'a, Fut>
Returns an iterator that allows modifying each future in the set.
Trait Implementations
impl<Fut> Default for FuturesUnordered<Fut> where
Fut: Future,
[src]
impl<Fut> Default for FuturesUnordered<Fut> where
Fut: Future,
fn default() -> FuturesUnordered<Fut>
[src]
fn default() -> FuturesUnordered<Fut>
Returns the "default value" for a type. Read more
impl<Fut> Unpin for FuturesUnordered<Fut>
[src]
impl<Fut> Unpin for FuturesUnordered<Fut>
impl<Fut> Drop for FuturesUnordered<Fut>
[src]
impl<Fut> Drop for FuturesUnordered<Fut>
impl<Fut> Sync for FuturesUnordered<Fut> where
Fut: Sync,
[src]
impl<Fut> Sync for FuturesUnordered<Fut> where
Fut: Sync,
impl<Fut> Send for FuturesUnordered<Fut> where
Fut: Send,
[src]
impl<Fut> Send for FuturesUnordered<Fut> where
Fut: Send,
impl<Fut> Debug for FuturesUnordered<Fut>
[src]
impl<Fut> Debug for FuturesUnordered<Fut>
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<Fut> Stream for FuturesUnordered<Fut> where
Fut: Future,
[src]
impl<Fut> Stream for FuturesUnordered<Fut> where
Fut: Future,
type Item = <Fut as Future>::Output
Values yielded by the stream.
fn poll_next(
self: PinMut<FuturesUnordered<Fut>>,
cx: &mut Context
) -> Poll<Option<<FuturesUnordered<Fut> as Stream>::Item>>
[src]
fn poll_next(
self: PinMut<FuturesUnordered<Fut>>,
cx: &mut Context
) -> Poll<Option<<FuturesUnordered<Fut> as Stream>::Item>>
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
impl<Fut> FromIterator<Fut> for FuturesUnordered<Fut> where
Fut: Future,
[src]
impl<Fut> FromIterator<Fut> for FuturesUnordered<Fut> where
Fut: Future,
fn from_iter<I>(iter: I) -> FuturesUnordered<Fut> where
I: IntoIterator<Item = Fut>,
[src]
fn from_iter<I>(iter: I) -> FuturesUnordered<Fut> where
I: IntoIterator<Item = Fut>,
Creates a value from an iterator. Read more