Struct FuturesUnordered
#[must_use = "streams do nothing unless polled"]
pub struct FuturesUnordered<Fut> { /* private fields */ }
A set of futures which may complete in any order.
See FuturesOrdered for a version of this
type that preserves a FIFO 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 collecting an
iterator of futures into a FuturesUnordered, or by
pushing 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
impl<Fut> FuturesUnordered<Fut>
fn new() -> SelfConstructs a new, empty
FuturesUnordered.The returned
FuturesUnordereddoes not contain any futures. In this state,FuturesUnordered::poll_nextwill returnPoll::Ready(None).fn len(&self) -> usizeReturns the number of futures contained in the set.
This represents the total number of in-flight futures.
fn is_empty(&self) -> boolReturns
trueif the set contains no futures.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
pollon the submitted future. The caller must ensure thatFuturesUnordered::poll_nextis called in order to receive wake-up notifications for the given future.fn iter(&self) -> Iter<'_, Fut> where Fut: Unpin,Returns an iterator that allows inspecting each future in the set.
fn iter_pin_ref(self: Pin<&Self>) -> IterPinRef<'_, Fut>Returns an iterator that allows inspecting each future in the set.
fn iter_mut(&mut self) -> IterMut<'_, Fut> where Fut: Unpin,Returns an iterator that allows modifying each future in the set.
fn iter_pin_mut(self: Pin<&mut Self>) -> IterPinMut<'_, Fut>Returns an iterator that allows modifying each future in the set.
impl<Fut> FuturesUnordered<Fut>
fn clear(&mut self)Clears the set, removing all futures.
Trait Implementations
impl LocalSpawn for FuturesUnordered<LocalFutureObj<'_, ()>>
fn spawn_local_obj(&self, future_obj: LocalFutureObj<'static, ()>) -> Result<(), SpawnError>
impl Spawn for FuturesUnordered<FutureObj<'_, ()>>
fn spawn_obj(&self, future_obj: FutureObj<'static, ()>) -> Result<(), SpawnError>
impl<Fut> Debug for FuturesUnordered<Fut>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<Fut> Default for FuturesUnordered<Fut>
fn default() -> Self
impl<Fut> Drop for FuturesUnordered<Fut>
fn drop(&mut self)
impl<Fut> Extend<Fut> for FuturesUnordered<Fut>
fn extend<I>(&mut self, iter: I) where I: IntoIterator<Item = Fut>,
impl<Fut> FromIterator<Fut> for FuturesUnordered<Fut>
fn from_iter<I>(iter: I) -> Self where I: IntoIterator<Item = Fut>,
impl<Fut> Unpin for FuturesUnordered<Fut>
impl<Fut: Future> FusedStream for FuturesUnordered<Fut>
fn is_terminated(&self) -> bool
impl<Fut: Future> Stream for FuturesUnordered<Fut>
type Item = <Fut as Future>::Output;fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>>fn size_hint(&self) -> (usize, Option<usize>)
impl<Fut: Send + Sync> Sync for FuturesUnordered<Fut>
impl<Fut: Send> Send for FuturesUnordered<Fut>
impl<Fut: Unpin> IntoIterator for FuturesUnordered<Fut>
type Item = Fut;type IntoIter = IntoIter<Fut>;fn into_iter(self) -> Self::IntoIter
Auto Trait Implementations
impl<Fut> !Freeze for FuturesUnordered<Fut>
impl<Fut> !RefUnwindSafe for FuturesUnordered<Fut>
impl<Fut> !UnwindSafe for FuturesUnordered<Fut>
impl<Fut> UnsafeUnpin for FuturesUnordered<Fut>
where
Arc<ReadyToRunQueue<Fut>>: UnsafeUnpin,
Atomic<*mut Task<Fut>>: UnsafeUnpin,
Blanket Implementations
impl<S> TryStreamExt for FuturesUnordered<Fut>
where
S: TryStream + ?Sized,
impl<S, T, E> TryStream for FuturesUnordered<Fut>
where
S: Stream<Item = Result<T, E>> + ?Sized,
type Ok = T;type Error = E;fn try_poll_next(self: Pin<&mut S>, cx: &mut Context<'_>) -> Poll<Option<Result<<S as TryStream>::Ok, <S as TryStream>::Error>>>
impl<Sp> LocalSpawnExt for FuturesUnordered<Fut>
where
Sp: LocalSpawn + ?Sized,
impl<Sp> SpawnExt for FuturesUnordered<Fut>
where
Sp: Spawn + ?Sized,
impl<T> Any for FuturesUnordered<Fut>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for FuturesUnordered<Fut>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for FuturesUnordered<Fut>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for FuturesUnordered<Fut>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> StreamExt for FuturesUnordered<Fut>
where
T: Stream + ?Sized,
impl<T, U> Into<U> for FuturesUnordered<Fut>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for FuturesUnordered<Fut>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for FuturesUnordered<Fut>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>