Struct promising_future::FutureStreamWaiter [] [src]

pub struct FutureStreamWaiter<'a, T: 'a> {
    // some fields omitted
}

Waiter for Futures in a FutureStream.

A singleton waiter for Futures, associated with a specific FutureStream. This may be used in a multithreaded environment to wait for Futures to resolve while other threads fulfill Promises and add new Futures to the FutureStream.

let fs = FutureStream::new();
fs.add(future);
// ...
let mut waiter = fs.waiter();
while let Some(future) = waiter.wait() {
    match future.value() {
      None => (),         // Future unfulfilled
      Some(val) => val,
    }
}

It may also be converted into an Iterator over the values yielded by resolved Futures (unfulfilled Promises are ignored).

let fs = FutureStream::new();
fs.add(fut1);
for val in fs.waiter() {
   // ...
}

Methods

impl<'fs, T> FutureStreamWaiter<'fs, T>

fn wait(&mut self) -> Option<Future<T>>

Return resolved Futures. Blocks if there are outstanding Futures which are not yet resolved. Returns None when there are no more outstanding Futures.

fn poll(&mut self) -> Option<Future<T>>

Return next resolved Future, but don't wait for more to resolve.

Trait Implementations

impl<'fs, T> Drop for FutureStreamWaiter<'fs, T>

fn drop(&mut self)

impl<'fs, T: 'fs> IntoIterator for FutureStreamWaiter<'fs, T>

type Item = T

type IntoIter = FutureStreamIter<'fs, T>

fn into_iter(self) -> Self::IntoIter