Skip to content

Commit c217ba2

Browse files
committed
---
yaml --- r: 31061 b: refs/heads/incoming c: 6c2c694 h: refs/heads/master i: 31059: f88edec v: v3
1 parent 2a1a8fc commit c217ba2

File tree

2 files changed

+16
-49
lines changed

2 files changed

+16
-49
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: 46371e107634ba9e8947cc1c45cecd8b24328e88
9+
refs/heads/incoming: 6c2c6947256db3841ceb3253ebace259a72dd917
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/doc/rust.md

Lines changed: 15 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2832,54 +2832,21 @@ exploiting.]
28322832

28332833
### Communication between tasks
28342834

2835-
With the exception of *unsafe* blocks, Rust tasks are isolated from
2836-
interfering with one another's memory directly. Instead of manipulating shared
2837-
storage, Rust tasks communicate with one another using a typed, asynchronous,
2838-
simplex message-passing system.
2839-
2840-
A _port_ is a communication endpoint that can *receive* messages. Ports
2841-
receive messages from channels.
2842-
2843-
A _channel_ is a communication endpoint that can *send* messages. Channels
2844-
send messages to ports.
2845-
2846-
Each port is implicitly boxed and mutable; as such a port has a unique
2847-
per-task identity and cannot be replicated or transmitted. If a port value is
2848-
copied, both copies refer to the *same* port. New ports can be
2849-
constructed dynamically and stored in data structures.
2850-
2851-
Each channel is bound to a port when the channel is constructed, so the
2852-
destination port for a channel must exist before the channel itself. A channel
2853-
cannot be rebound to a different port from the one it was constructed with.
2854-
2855-
Channels are weak: a channel does not keep the port it is bound to
2856-
alive. Ports are owned by their allocating task and cannot be sent over
2857-
channels; if a task dies its ports die with it, and all channels bound to
2858-
those ports no longer function. Messages sent to a channel connected to a dead
2859-
port will be dropped.
2860-
2861-
Channels are immutable types with meaning known to the runtime; channels can
2862-
be sent over channels.
2863-
2864-
Many channels can be bound to the same port, but each channel is bound to a
2865-
single port. In other words, channels and ports exist in an N:1 relationship,
2866-
N channels to 1 port. ^[It may help to remember nautical terminology
2867-
when differentiating channels from ports. Many different waterways --
2868-
channels -- may lead to the same port.]
2869-
2870-
Each port and channel can carry only one type of message. The message type is
2871-
encoded as a parameter of the channel or port type. The message type of a
2872-
channel is equal to the message type of the port it is bound to. The types of
2873-
messages must satisfy the `send` built-in trait.
2874-
2875-
Messages are generally sent asynchronously, with optional
2876-
rate-limiting on the transmit side. Each port contains a message
2877-
queue and sending a message over a channel merely means inserting it
2878-
into the associated port's queue; message receipt is the
2879-
responsibility of the receiving task.
2880-
2881-
Messages are sent on channels and received on ports using standard library
2882-
functions.
2835+
Rust tasks are isolated and generally unable to interfere with one another's memory directly,
2836+
except through [`unsafe` code](#unsafe-code).
2837+
All contact between tasks is mediated by safe forms of ownership transfer,
2838+
and data races on memory are prohibited by the type system.
2839+
2840+
Inter-task communication and co-ordination facilities are provided in the standard library.
2841+
These include:
2842+
- synchronous and asynchronous communication channels with various communication topologies
2843+
- read-only and read-write shared variables with various safe mutual exclusion patterns
2844+
- simple locks and semaphores
2845+
2846+
When such facilities carry values, the values are restricted to the [`Send` type-kind](#type-kinds).
2847+
Restricting communication interfaces to this kind ensures that no borrowed or managed pointers move between tasks.
2848+
Thus access to an entire data structure can be mediated through its owning "root" value;
2849+
no further locking or copying is required to avoid data races within the substructure of such a value.
28832850

28842851

28852852
### Task lifecycle

0 commit comments

Comments
 (0)