Module std::taskUnstable
[-]
[+]
[src]
Task creation
An executing Rust program consists of a collection of tasks, each with their own stack and local state.
Tasks generally have their memory isolated from each other by
virtue of Rust's owned types (which of course may only be owned by
a single task at a time). Communication between tasks is primarily
done through channels, Rust's
message-passing types, though other forms of task
synchronization are often employed to
achieve particular performance goals. In particular, types that
are guaranteed to be threadsafe are easily shared between threads
using the atomically-reference-counted container,
Arc.
Fatal logic errors in Rust cause task panic, during which a task will unwind the stack, running destructors and freeing owned resources. Task panic is unrecoverable from within the panicking task (i.e. there is no 'try/catch' in Rust), but panic may optionally be detected from a different task. If the main task panics the application will exit with a non-zero exit code.
Example
fn main() { spawn(proc() { println!("Hello, World!"); }) }spawn(proc() { println!("Hello, World!"); })
Structs
| TaskBuilder | The task builder type. |
Functions
| deschedule | Yield control to the task scheduler. |
| failing | True if the running task is currently panicking (e.g. will return |
| name | Read the name of the current task. |
| spawn | Creates and executes a new child task |
| try | Execute a function in a newly-spawned task and return either the return value of the function or an error if the task panicked. |
| try_future | Execute a function in another task and return a future representing the task's result. |