Skip to content

Commit b09985e

Browse files
committed
auto merge of rust-lang#15047 : brson/rust/taskdocs, r=huonw
This corrects some misinformation.
2 parents 3047614 + cb89880 commit b09985e

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

src/libstd/task.rs

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,33 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Utilities for managing and scheduling tasks
11+
//! Task creation
1212
//!
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).
1719
//!
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.
2238
//!
2339
//! # Basic task scheduling
2440
//!

0 commit comments

Comments
 (0)