|
1 | 1 | #[doc(
|
2 | 2 | brief = "Communication between tasks",
|
3 |
| - desc = "Communication between tasks is facilitated by ports (in the \ |
4 |
| - receiving task), and channels (in the sending task). Any \ |
5 |
| - number of channels may feed into a single port. \ |
6 |
| - Ports and channels may only transmit values of unique \ |
7 |
| - types; that is, values that are statically guaranteed to \ |
8 |
| - be accessed by a single 'owner' at a time. Unique types \ |
9 |
| - include scalars, vectors, strings, and records, tags, \ |
10 |
| - tuples and unique boxes (~T) thereof. Most notably, \ |
11 |
| - shared boxes (@T) may not be transmitted across channels. \ |
12 |
| - Example: \ |
13 |
| - let p = comm::port(); \ |
14 |
| - task::spawn(comm::chan(p), fn (c: chan<str>) { \ |
15 |
| - comm::send(c, \"Hello, World\"); \ |
16 |
| - }); \ |
17 |
| - io::println(comm::recv(p));" |
18 |
| -)]; |
| 3 | + desc = " |
| 4 | +
|
| 5 | +Communication between tasks is facilitated by ports (in the receiving |
| 6 | +task), and channels (in the sending task). Any number of channels may |
| 7 | +feed into a single port. Ports and channels may only transmit values |
| 8 | +of unique types; that is, values that are statically guaranteed to be |
| 9 | +accessed by a single 'owner' at a time. Unique types include scalars, |
| 10 | +vectors, strings, and records, tags, tuples and unique boxes (`~T`) |
| 11 | +thereof. Most notably, shared boxes (`@T`) may not be transmitted |
| 12 | +across channels. |
| 13 | +
|
| 14 | +Example: |
| 15 | +
|
| 16 | + let p = comm::port(); |
| 17 | + task::spawn(comm::chan(p), fn (c: chan<str>) { |
| 18 | + comm::send(c, \"Hello, World\"); |
| 19 | + }); |
| 20 | + io::println(comm::recv(p)); |
| 21 | +
|
| 22 | +")]; |
19 | 23 |
|
20 | 24 | import sys;
|
21 | 25 | import task;
|
|
0 commit comments