Struct promising_future::FutureStreamWaiter
[−]
[src]
pub struct FutureStreamWaiter<'a, T: Send + 'a> { // some fields omitted }
Waiter for Future
s in a FutureStream
.
A singleton waiter for Future
s, 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 Future
s 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 Future
s
(unfulfilled Promise
s are ignored).
let fs = FutureStream::new(); fs.add(fut1); for val in fs.waiter() { // ... }
Methods
impl<'fs, T: Send> FutureStreamWaiter<'fs, T>
fn wait(&mut self) -> Option<Future<T>>
Return resolved Future
s. Blocks if there are outstanding Futures
which are not yet
resolved. Returns None
when there are no more outstanding Future
s.
fn poll(&mut self) -> Option<Future<T>>
Return next resolved Future
, but don't wait for more to resolve.