[−][src]Struct futures_util::stream::FuturesUnordered
#[must_use = "streams do nothing unless polled"]pub struct FuturesUnordered<Fut> { /* fields omitted */ }
A set of futures 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 wake-up 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 futures into a FuturesUnordered
, or by
push
ing futures onto an existing
FuturesUnordered
. When new futures are added,
poll_next
must be called in order to begin receiving
wake-ups for new futures.
Note that you can create a ready-made FuturesUnordered
via the
futures_unordered
function, or you can start with
an empty set with the FuturesUnordered::new
constructor.
Methods
impl<Fut: Future> FuturesUnordered<Fut>
[src]
impl<Fut: Future> FuturesUnordered<Fut>
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 method adds the given future to the set. This method will not
call poll
on the submitted future. The caller must
ensure that FuturesUnordered::poll_next
is called
in order to receive wake-up notifications for the given future.
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<'a>(self: PinMut<'a, Self>) -> IterPinMut<'a, Fut>
[src]
pub fn iter_pin_mut<'a>(self: PinMut<'a, Self>) -> IterPinMut<'a, Fut>
Returns an iterator that allows modifying each future in the set.
Trait Implementations
impl<Fut: Send> Send for FuturesUnordered<Fut>
[src]
impl<Fut: Send> Send for FuturesUnordered<Fut>
impl<Fut: Sync> Sync for FuturesUnordered<Fut>
[src]
impl<Fut: Sync> Sync for FuturesUnordered<Fut>
impl<Fut> Unpin for FuturesUnordered<Fut>
[src]
impl<Fut> Unpin for FuturesUnordered<Fut>
impl<Fut: Future> Default for FuturesUnordered<Fut>
[src]
impl<Fut: Future> Default for FuturesUnordered<Fut>
fn default() -> FuturesUnordered<Fut>
[src]
fn default() -> FuturesUnordered<Fut>
Returns the "default value" for a type. Read more
impl<Fut: Future> Stream for FuturesUnordered<Fut>
[src]
impl<Fut: Future> Stream for FuturesUnordered<Fut>
type Item = Fut::Output
Values yielded by the stream.
fn poll_next(self: PinMut<Self>, cx: &mut Context) -> Poll<Option<Self::Item>>
[src]
fn poll_next(self: PinMut<Self>, cx: &mut Context) -> Poll<Option<Self::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> Debug for FuturesUnordered<Fut>
[src]
impl<Fut> Debug for FuturesUnordered<Fut>
fn fmt(&self, fmt: &mut Formatter) -> Result
[src]
fn fmt(&self, fmt: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<Fut> Drop for FuturesUnordered<Fut>
[src]
impl<Fut> Drop for FuturesUnordered<Fut>
impl<Fut: Future> FromIterator<Fut> for FuturesUnordered<Fut>
[src]
impl<Fut: Future> FromIterator<Fut> for FuturesUnordered<Fut>
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = Fut>,
[src]
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = Fut>,
Creates a value from an iterator. Read more