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

pub struct TaskBuilder<S = SiblingSpawner> {
    // some fields omitted
}

The task builder type.

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

Methods

impl TaskBuilder<SiblingSpawner>

fn new() -> TaskBuilder<SiblingSpawner>

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

impl<S: Spawner> TaskBuilder<S>

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

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

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

Set the size of the stack for the new task.

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

Redirect task-local stdout.

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

Redirect task-local stderr.

fn spawner<T: Spawner>(self, spawner: T) -> TaskBuilder<T>

Set the spawning mechanism for the task.

The TaskBuilder API configures a task to be spawned, but defers to the "spawner" to actually create and spawn the task. The spawner method should not be called directly by TaskBuiler clients. It is intended for use by downstream crates (like native and green) that implement tasks. These downstream crates then add extension methods to the builder, like .native() and .green(pool), that actually set the spawner.

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().