[src]

Module std::task

Utilities for managing and scheduling tasks

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 (see std::rt::comm for more info about how communication works).

Tasks can be spawned in 3 different modes.

Tasks' failure modes can be further configured. For instance, parent tasks can (un)watch children failures. Please, refer to TaskBuilder's documentation bellow for more information.

When a (bi|uni)directionally linked task fails, its failure will be propagated to all tasks linked to it, this will cause such tasks to fail by a linked failure.

Task Scheduling:

By default, every task is created in the same scheduler as its parent, where it is scheduled cooperatively with all other tasks in that scheduler. Some specialized applications may want more control over their scheduling, in which case they can be spawned into a new scheduler with the specific properties required. See TaskBuilder's documentation bellow for more information.

Example

do spawn {
    log(error, "Hello, World!");
}

Structs

TaskBuilder

The task builder type.

TaskOpts

Task configuration options

Functions

deschedule

Yield control to the task scheduler

failing

True if the running task has failed

spawn

Creates and executes a new child task

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.

with_task_name

Read the name of the current task.

Type Definitions

TaskResult

Indicates the manner in which a task exited.