[src]

Struct std::task::TaskBuilder

pub struct TaskBuilder {
    opts: TaskOpts,
    // some fields omitted
}

The task builder type.

Provides detailed control over the properties and behavior of new tasks.

Fields

opts

Options to spawn the new task with

Methods

impl TaskBuilder

fn future_result(&mut self) -> Receiver<TaskResult>

Get a future representing the exit status of the task.

Taking the value of the future will block until the child task terminates. The future result return value will be created before the task is spawned; as such, do not invoke .get() on it directly; rather, store it in an outer variable/list for later use.

Failure

Fails if a future_result was already set for this task.

fn named<S: IntoMaybeOwned<'static>>(self, name: S) -> TaskBuilder

Name the task-to-be. Currently the name is used for identification only in failure messages.

fn with_wrapper(self, wrapper: proc(v: proc()) -> proc()) -> TaskBuilder

Add a wrapper to the body of the spawned task.

Before the task is spawned it is passed through a 'body generator' function that may perform local setup operations as well as wrap the task body in remote setup operations. With this the behavior of tasks can be extended in simple ways.

This function augments the current body generator with a new body generator by applying the task body which results from the existing body generator to the new body generator.

fn spawn(self, f: proc())

Creates and executes a new child task

Sets up a new task with its own call stack and schedules it to run the provided unique closure. The task has the properties and behavior specified by the task_builder.

fn try<T: Send>(self, f: proc() -> T) -> Result<T, ~Any<Send>>

Execute a function in another task and return either the return value of the function or result::err.

Return value

If the function executed successfully then try returns result::ok containing the value returned by the function. If the function fails then try returns result::err containing nil.

Failure

Fails if a future_result was already set for this task.