A type representing values that may be computed concurrently and operations for working with them.

Example

let delayed_fib = future::spawn {|| fib(5000) };
make_a_sandwich();
io::println(fmt!("fib(5000) = %?", delayed_fib.get()))

Enum FutureState

Variants

Struct Future

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

The future type

Implementation of Drop for Future<A>

Method finalize

fn finalize()

Implementation for Future<A>

Methods on the future type

Method get

fn get() -> A

Get the value of the future

Implementation for Future<A>

Method get_ref

fn get_ref() -> &self /A

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

Function from_fn

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

Create a future from a function.

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

Function from_port

fn from_port<A: Owned>(port: PortOne<A>) -> 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.

Function from_value

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

Create a future from a value

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

Function spawn

fn spawn<A: Owned>(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.