|
8 | 8 | // option. This file may not be copied, modified, or distributed
|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 |
| -//! Utilities for managing and scheduling tasks |
| 11 | +//! Task creation |
12 | 12 | //!
|
13 |
| -//! An executing Rust program consists of a collection of lightweight tasks, |
14 |
| -//! each with their own stack. Tasks communicate with each other using channels |
15 |
| -//! (see `std::comm`) or other forms of synchronization (see `std::sync`) that |
16 |
| -//! ensure data-race freedom. |
| 13 | +//! An executing Rust program consists of a collection of tasks, each |
| 14 | +//! with their own stack and local state. A Rust task is typically |
| 15 | +//! backed by an operating system thread, making tasks 'just threads', |
| 16 | +//! but may also be implemented via other strategies as well |
| 17 | +//! (e.g. Rust comes with the [`green`](../../green/index.html) |
| 18 | +//! scheduling crate for creating tasks backed by green threads). |
17 | 19 | //!
|
18 |
| -//! Failure in one task does immediately propagate to any others (not to parent, |
19 |
| -//! not to child). Failure propagation is instead handled as part of task |
20 |
| -//! synchronization. For example, the channel `send()` and `recv()` methods will |
21 |
| -//! fail if the other end has hung up already. |
| 20 | +//! Tasks generally have their memory *isolated* from each other by |
| 21 | +//! virtue of Rust's owned types (which of course may only be owned by |
| 22 | +//! a single task at a time). Communication between tasks is primarily |
| 23 | +//! done through [channels](../../std/comm/index.html), Rust's |
| 24 | +//! message-passing types, though [other forms of task |
| 25 | +//! synchronization](../../std/sync/index.html) are often employed to |
| 26 | +//! achieve particular performance goals. In particular, types that |
| 27 | +//! are guaranteed to be threadsafe are easily shared between threads |
| 28 | +//! using the atomically-reference-counted container, |
| 29 | +//! [`Arc`](../../std/sync/struct.Arc.html). |
| 30 | +//! |
| 31 | +//! Fatal logic errors in Rust cause *task failure*, during which |
| 32 | +//! a task will unwind the stack, running destructors and freeing |
| 33 | +//! owned resources. Task failure is unrecoverable from within |
| 34 | +//! the failing task (i.e. there is no 'try/catch' in Rust), but |
| 35 | +//! failure may optionally be detected from a different task. If |
| 36 | +//! the main task fails the application will exit with a non-zero |
| 37 | +//! exit code. |
22 | 38 | //!
|
23 | 39 | //! # Basic task scheduling
|
24 | 40 | //!
|
|
0 commit comments