Struct futures_util::stream::FuturesUnordered
source · [−]pub struct FuturesUnordered<Fut> { /* private fields */ }
Expand description
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
collect
method, or you can start with an empty set
with the FuturesUnordered::new
constructor.
This type is only available when the std
or alloc
feature of this
library is activated, and it is activated by default.
Implementations
sourceimpl<Fut> FuturesUnordered<Fut>
impl<Fut> FuturesUnordered<Fut>
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new, empty FuturesUnordered
.
The returned FuturesUnordered
does not contain any futures.
In this state, FuturesUnordered::poll_next
will
return Poll::Ready(None)
.
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.
sourcepub fn push(&self, future: Fut)
pub fn push(&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.
sourcepub fn iter(&self) -> Iter<'_, Fut>ⓘNotable traits for Iter<'a, Fut>impl<'a, Fut: Unpin> Iterator for Iter<'a, Fut> type Item = &'a Fut;
where
Fut: Unpin,
pub fn iter(&self) -> Iter<'_, Fut>ⓘNotable traits for Iter<'a, Fut>impl<'a, Fut: Unpin> Iterator for Iter<'a, Fut> type Item = &'a Fut;
where
Fut: Unpin,
Returns an iterator that allows inspecting each future in the set.
sourcepub fn iter_pin_ref(self: Pin<&Self>) -> IterPinRef<'_, Fut>ⓘNotable traits for IterPinRef<'a, Fut>impl<'a, Fut> Iterator for IterPinRef<'a, Fut> type Item = Pin<&'a Fut>;
pub fn iter_pin_ref(self: Pin<&Self>) -> IterPinRef<'_, Fut>ⓘNotable traits for IterPinRef<'a, Fut>impl<'a, Fut> Iterator for IterPinRef<'a, Fut> type Item = Pin<&'a Fut>;
Returns an iterator that allows inspecting each future in the set.
sourcepub fn iter_mut(&mut self) -> IterMut<'_, Fut>ⓘNotable traits for IterMut<'a, Fut>impl<'a, Fut: Unpin> Iterator for IterMut<'a, Fut> type Item = &'a mut Fut;
where
Fut: Unpin,
pub fn iter_mut(&mut self) -> IterMut<'_, Fut>ⓘNotable traits for IterMut<'a, Fut>impl<'a, Fut: Unpin> Iterator for IterMut<'a, Fut> type Item = &'a mut Fut;
where
Fut: Unpin,
Returns an iterator that allows modifying each future in the set.
sourcepub fn iter_pin_mut(self: Pin<&mut Self>) -> IterPinMut<'_, Fut>ⓘNotable traits for IterPinMut<'a, Fut>impl<'a, Fut> Iterator for IterPinMut<'a, Fut> type Item = Pin<&'a mut Fut>;
pub fn iter_pin_mut(self: Pin<&mut Self>) -> IterPinMut<'_, Fut>ⓘNotable traits for IterPinMut<'a, Fut>impl<'a, Fut> Iterator for IterPinMut<'a, Fut> type Item = Pin<&'a mut Fut>;
Returns an iterator that allows modifying each future in the set.
sourceimpl<Fut> FuturesUnordered<Fut>
impl<Fut> FuturesUnordered<Fut>
Trait Implementations
sourceimpl<Fut> Debug for FuturesUnordered<Fut>
impl<Fut> Debug for FuturesUnordered<Fut>
sourceimpl<Fut> Default for FuturesUnordered<Fut>
impl<Fut> Default for FuturesUnordered<Fut>
sourceimpl<Fut> Drop for FuturesUnordered<Fut>
impl<Fut> Drop for FuturesUnordered<Fut>
sourceimpl<Fut> Extend<Fut> for FuturesUnordered<Fut>
impl<Fut> Extend<Fut> for FuturesUnordered<Fut>
sourcefn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = Fut>,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = Fut>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<Fut> FromIterator<Fut> for FuturesUnordered<Fut>
impl<Fut> FromIterator<Fut> for FuturesUnordered<Fut>
sourcefn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = Fut>,
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = Fut>,
Creates a value from an iterator. Read more
sourceimpl<Fut: Future> FusedStream for FuturesUnordered<Fut>
impl<Fut: Future> FusedStream for FuturesUnordered<Fut>
sourcefn is_terminated(&self) -> bool
fn is_terminated(&self) -> bool
Returns true
if the stream should no longer be polled.
sourceimpl<'a, Fut: Unpin> IntoIterator for &'a FuturesUnordered<Fut>
impl<'a, Fut: Unpin> IntoIterator for &'a FuturesUnordered<Fut>
sourceimpl<'a, Fut: Unpin> IntoIterator for &'a mut FuturesUnordered<Fut>
impl<'a, Fut: Unpin> IntoIterator for &'a mut FuturesUnordered<Fut>
sourceimpl<Fut: Unpin> IntoIterator for FuturesUnordered<Fut>
impl<Fut: Unpin> IntoIterator for FuturesUnordered<Fut>
sourceimpl LocalSpawn for FuturesUnordered<LocalFutureObj<'_, ()>>
impl LocalSpawn for FuturesUnordered<LocalFutureObj<'_, ()>>
sourcefn spawn_local_obj(
&self,
future_obj: LocalFutureObj<'static, ()>
) -> Result<(), SpawnError>
fn spawn_local_obj(
&self,
future_obj: LocalFutureObj<'static, ()>
) -> Result<(), SpawnError>
Spawns a future that will be run to completion. Read more
sourcefn status_local(&self) -> Result<(), SpawnError>
fn status_local(&self) -> Result<(), SpawnError>
Determines whether the executor is able to spawn new tasks. Read more
sourceimpl Spawn for FuturesUnordered<FutureObj<'_, ()>>
impl Spawn for FuturesUnordered<FutureObj<'_, ()>>
sourceimpl<Fut: Future> Stream for FuturesUnordered<Fut>
impl<Fut: Future> Stream for FuturesUnordered<Fut>
impl<Fut: Send> Send for FuturesUnordered<Fut>
impl<Fut: Sync> Sync for FuturesUnordered<Fut>
impl<Fut> Unpin for FuturesUnordered<Fut>
Auto Trait Implementations
impl<Fut> !RefUnwindSafe for FuturesUnordered<Fut>
impl<Fut> !UnwindSafe for FuturesUnordered<Fut>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more