Struct extra::future::Future

pub struct Future<A> {
    priv state: FutureState<A>,
}

A type encapsulating the result of a computation which may not be complete

Methods

impl<A: std::clone::Clone> Future<A>

fn get(&mut self) -> A

Get the value of the future.

impl<A> Future<A>

fn unwrap(self) -> A

Gets the value from this future, forcing evaluation.

fn get_ref<'a>(&'a mut self) -> &'a A

Executes the future's closure and then returns a borrowed pointer to the result. The borrowed pointer lasts as long as the future.

fn from_value(val: A) -> Future<A>

Create a future from a value.

The value is immediately available and calling get later will not block.

fn from_fn(f: ~fn() -> A) -> Future<A>

Create a future from a function.

The first time that the value is requested it will be retrieved by calling the function. Note that this function is a local function. It is not spawned into another task.

impl<A: std::kinds::Send> Future<A>

fn from_port(port: std::comm::PortOne) -> Future<A>

Create a future from a port

The first time that the value is requested the task will block waiting for the result to be received on the port.

fn spawn(blk: ~fn() -> A) -> Future<A>

Create a future from a unique closure.

The closure will be run in a new task and its result used as the value of the future.

fn spawn_with<B: std::kinds::Send>(v: B, blk: ~fn(B) -> A) -> Future<A>

Create a future from a unique closure taking one argument.

The closure and its argument will be moved into a new task. The closure will be run and its result used as the value of the future.