File tree Expand file tree Collapse file tree 3 files changed +21
-10
lines changed Expand file tree Collapse file tree 3 files changed +21
-10
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ minutes: 8
4
4
5
5
# Bounded Channels
6
6
7
- With bounded (synchronous) channels, ` send ` can block the current thread:
7
+ With bounded (synchronous) channels, [ ` send() ` ] can block the current thread:
8
8
9
9
``` rust,editable
10
10
use std::sync::mpsc;
@@ -32,12 +32,15 @@ fn main() {
32
32
33
33
<details >
34
34
35
- - Calling ` send ` will block the current thread until there is space in the
35
+ - Calling ` send() ` will block the current thread until there is space in the
36
36
channel for the new message. The thread can be blocked indefinitely if there
37
37
is nobody who reads from the channel.
38
- - A call to ` send ` will abort with an error (that is why it returns ` Result ` ) if
39
- the channel is closed. A channel is closed when the receiver is dropped.
38
+ - A call to ` send() ` will abort with an error (that is why it returns ` Result ` )
39
+ if the channel is closed. A channel is closed when the receiver is dropped.
40
40
- A bounded channel with a size of zero is called a "rendezvous channel". Every
41
- send will block the current thread until another thread calls ` recv ` .
41
+ send will block the current thread until another thread calls [ ` recv() ` ] .
42
42
43
43
</details >
44
+
45
+ [ `send()` ] : https://doc.rust-lang.org/std/sync/mpsc/struct.SyncSender.html#method.send
46
+ [ `recv()` ] : https://doc.rust-lang.org/std/sync/mpsc/struct.Receiver.html#method.recv
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ minutes: 9
4
4
5
5
# Senders and Receivers
6
6
7
- Rust channels have two parts: a ` Sender<T> ` and a ` Receiver<T> ` . The two parts
8
- are connected via the channel, but you only see the end-points.
7
+ Rust channels have two parts: a [ ` Sender<T> ` ] and a [ ` Receiver<T> ` ] . The two
8
+ parts are connected via the channel, but you only see the end-points.
9
9
10
10
``` rust,editable
11
11
use std::sync::mpsc;
@@ -27,10 +27,16 @@ fn main() {
27
27
28
28
<details >
29
29
30
- - ` mpsc ` stands for Multi-Producer, Single-Consumer. ` Sender ` and ` SyncSender `
30
+ - [ ` mpsc ` ] stands for Multi-Producer, Single-Consumer. ` Sender ` and ` SyncSender `
31
31
implement ` Clone ` (so you can make multiple producers) but ` Receiver ` does
32
32
not.
33
- - ` send() ` and ` recv() ` return ` Result ` . If they return ` Err ` , it means the
33
+ - [ ` send() ` ] and [ ` recv() ` ] return ` Result ` . If they return ` Err ` , it means the
34
34
counterpart ` Sender ` or ` Receiver ` is dropped and the channel is closed.
35
35
36
36
</details >
37
+
38
+ [ `Sender<T>` ] : https://doc.rust-lang.org/std/sync/mpsc/struct.Sender.html
39
+ [ `Receiver<T>` ] : https://doc.rust-lang.org/std/sync/mpsc/struct.Receiver.html
40
+ [ `send()` ] : https://doc.rust-lang.org/std/sync/mpsc/struct.Sender.html#method.send
41
+ [ `recv()` ] : https://doc.rust-lang.org/std/sync/mpsc/struct.Receiver.html#method.recv
42
+ [ `mpsc` ] : https://doc.rust-lang.org/std/sync/mpsc/index.html
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ minutes: 2
4
4
5
5
# Unbounded Channels
6
6
7
- You get an unbounded and asynchronous channel with ` mpsc::channel() ` :
7
+ You get an unbounded and asynchronous channel with [ ` mpsc::channel() ` ] :
8
8
9
9
``` rust,editable
10
10
use std::sync::mpsc;
@@ -29,3 +29,5 @@ fn main() {
29
29
}
30
30
}
31
31
```
32
+
33
+ [ `mpsc::channel()` ] : https://doc.rust-lang.org/std/sync/mpsc/fn.channel.html
You can’t perform that action at this time.
0 commit comments