[−][src]Struct futures_util::stream::futures_unordered::FuturesUnordered
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.
Methods
impl<Fut: Future> FuturesUnordered<Fut>
[src]
pub fn new() -> FuturesUnordered<Fut>
[src]
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]
pub fn len(&self) -> usize
[src]
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]
Returns true
if the set contains no futures.
pub fn push(&self, future: Fut)
[src]
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.
ⓘImportant traits for Iter<'a, Fut>pub fn iter(&self) -> Iter<Fut> where
Fut: Unpin,
[src]
Fut: Unpin,
Returns an iterator that allows inspecting each future in the set.
ⓘImportant traits for IterMut<'a, Fut>pub fn iter_mut(&mut self) -> IterMut<Fut> where
Fut: Unpin,
[src]
Fut: Unpin,
Returns an iterator that allows modifying each future in the set.
ⓘImportant traits for IterPinMut<'a, Fut>pub fn iter_pin_mut(self: Pin<&mut Self>) -> IterPinMut<Fut>
[src]
Returns an iterator that allows modifying each future in the set.
Trait Implementations
impl<Fut: Send> Send for FuturesUnordered<Fut>
[src]
impl<Fut: Sync> Sync for FuturesUnordered<Fut>
[src]
impl<Fut> Unpin for FuturesUnordered<Fut>
[src]
impl<Fut> Drop for FuturesUnordered<Fut>
[src]
impl<Fut: Future> Default for FuturesUnordered<Fut>
[src]
fn default() -> FuturesUnordered<Fut>
[src]
impl<Fut> Debug for FuturesUnordered<Fut>
[src]
impl<Fut: Future> FromIterator<Fut> for FuturesUnordered<Fut>
[src]
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = Fut>,
[src]
I: IntoIterator<Item = Fut>,
impl<Fut: Future> Stream for FuturesUnordered<Fut>
[src]
type Item = Fut::Output
Values yielded by the stream.
fn poll_next(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>>
[src]
fn size_hint(&self) -> (usize, Option<usize>)
[src]
impl<Fut: Future> FusedStream for FuturesUnordered<Fut>
[src]
fn is_terminated(&self) -> bool
[src]
impl<'_> Spawn for FuturesUnordered<FutureObj<'_, ()>>
[src]
fn spawn_obj(
&self,
future_obj: FutureObj<'static, ()>
) -> Result<(), SpawnError>
[src]
&self,
future_obj: FutureObj<'static, ()>
) -> Result<(), SpawnError>
fn status(&self) -> Result<(), SpawnError>
[src]
impl<'_> LocalSpawn for FuturesUnordered<LocalFutureObj<'_, ()>>
[src]
fn spawn_local_obj(
&self,
future_obj: LocalFutureObj<'static, ()>
) -> Result<(), SpawnError>
[src]
&self,
future_obj: LocalFutureObj<'static, ()>
) -> Result<(), SpawnError>
fn status_local(&self) -> Result<(), SpawnError>
[src]
Auto Trait Implementations
impl<Fut> !UnwindSafe for FuturesUnordered<Fut>
impl<Fut> !RefUnwindSafe for FuturesUnordered<Fut>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
ⓘImportant traits for &'_ mut Ffn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<S, T, E> TryStream for S where
S: Stream<Item = Result<T, E>> + ?Sized,
[src]
S: Stream<Item = Result<T, E>> + ?Sized,