[src]

Struct sync::Future

pub struct Future<A> {
    // some fields omitted
}

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

Methods

impl<A: Clone> Future<A>

Methods on the future type

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 reference to the result. The reference 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: proc() -> 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: Send> Future<A>

fn from_receiver(rx: Receiver<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.

fn spawn(blk: proc() -> 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.