Task management.
An executing Rust program consists of a tree of tasks, each with their own stack, and sole ownership of their allocated heap data. Tasks communicate with each other using ports and channels.
When a task fails, that failure will propagate to its parent (the task that spawned it) and the parent will fail as well. The reverse is not true: when a parent task fails its children will continue executing. When the root (main) task fails, all tasks fail, and then so does the entire process.
Tasks may execute in parallel and are scheduled automatically by the runtime.
do spawn {
log(error, "Hello, World!");
}
SchedOpts | Scheduler configuration options |
TaskBuilder | The task builder type. |
TaskOpts | Task configuration options |
SchedMode | Scheduler modes |
TaskResult | Indicates the manner in which a task exited. |
default_task_opts | The default task options |
deschedule | Yield control to the task scheduler |
failing | True if the running task has failed |
rekillable | Makes killable a task marked as unkillable. This is meant to be used only nested in unkillable. |
spawn | Creates and executes a new child task |
spawn_indestructible | Creates a child task that cannot be killed by linked failure. This causes its context-switch path to be faster by 2 atomic swap operations. (Note that this convenience wrapper still uses linked-failure, so the child's children will still be killable by the parent. For the fastest possible spawn mode, use task::task().unlinked().indestructible().spawn.) |
spawn_sched |
|
spawn_supervised | Creates a child task supervised by the current one. If the child task fails, the parent will not be killed, but if the parent fails, the child will be killed. |
spawn_unlinked | Creates a child task unlinked from the current one. If either this task or the child task fails, the other will not be killed. |
spawn_with | Runs a task, while transferring ownership of one argument to the child. |
task | Generate the base configuration for spawning a task, off of which more configuration methods can be chained. For example, task().unlinked().spawn is equivalent to spawn_unlinked. |
try | Execute a function in another task and return either the return value of the function or result::err. |
unkillable | Temporarily make the task unkillable |
with_task_name | Read the name of the current task. |
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).