Type Alias unicycle::FuturesUnordered

source ·
pub type FuturesUnordered<T> = Unordered<T, Futures>;
Expand description

A container for an unordered collection of Futures.

§Examples

use tokio::time;
use std::time::Duration;

#[tokio::main]
async fn main() {
    let mut futures = unicycle::FuturesUnordered::new();

    futures.push(time::sleep(Duration::from_secs(2)));
    futures.push(time::sleep(Duration::from_secs(3)));
    futures.push(time::sleep(Duration::from_secs(1)));

    while let Some(_) = futures.next().await {
        println!("tick");
    }

    println!("done!");
}

Aliased Type§

struct FuturesUnordered<T> { /* private fields */ }

Implementations§

source§

impl<T> FuturesUnordered<T>

source

pub fn new() -> Self

Construct a new, empty FuturesUnordered.

§Examples
use unicycle::FuturesUnordered;

let mut futures = FuturesUnordered::new();
assert!(futures.is_empty());

futures.push(async { 42 });

Trait Implementations§

source§

impl<T> FromIterator<T> for FuturesUnordered<T>
where T: Future,

source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
source§

impl<T> PollNext for FuturesUnordered<T>
where T: Future,

source§

fn poll_next( self: Pin<&mut Self>, cx: &mut Context<'_> ) -> Poll<Option<T::Output>>

Internal poll function for FuturesUnordered<T>.

§

type Item = <T as Future>::Output

The output of the poll.