Struct std::task::TaskBuilderUnstable [-]  [+] [src]

pub struct TaskBuilder {
    // some fields omitted
}

The task builder type.

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

Methods

impl TaskBuilder

fn new() -> TaskBuilder

Generate the base configuration for spawning a task, off of which more configuration methods can be chained.

impl TaskBuilder

fn named<T: IntoCow<'static, String, str>>(self, name: T) -> TaskBuilder

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

fn stack_size(self, size: uint) -> TaskBuilder

Set the size of the stack for the new task.

fn stdout(self, stdout: Box<Writer + Send>) -> TaskBuilder

Redirect task-local stdout.

fn stderr(self, stderr: Box<Writer + Send>) -> TaskBuilder

Redirect task-local stderr.

fn spawn(self, f: proc(): Send)

Creates and executes a new child task.

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

fn try_future<T: Send>(self, f: proc(): Send -> T) -> Future<Result<T, Box<Any + Send>>>

Execute a proc in a newly-spawned task and return a future representing the task's result. The task has the properties and behavior specified by the TaskBuilder.

Taking the value of the future will block until the child task terminates.

Return value

If the child task executes successfully (without panicking) then the future returns result::Ok containing the value returned by the function. If the child task panics then the future returns result::Err containing the argument to panic!(...) as an Any trait object.

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

Execute a function in a newly-spawnedtask and block until the task completes or panics. Equivalent to .try_future(f).unwrap().