From 1a86faf8ab0056ee18b61f2b191963702e4a322a Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Sun, 24 Mar 2024 11:16:34 +0000 Subject: [PATCH] Links in channel pages --- src/concurrency/channels/bounded.md | 13 ++++++++----- src/concurrency/channels/senders-receivers.md | 14 ++++++++++---- src/concurrency/channels/unbounded.md | 4 +++- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/concurrency/channels/bounded.md b/src/concurrency/channels/bounded.md index e1667d4f..b1500b34 100644 --- a/src/concurrency/channels/bounded.md +++ b/src/concurrency/channels/bounded.md @@ -4,7 +4,7 @@ minutes: 8 # Bounded Channels -With bounded (synchronous) channels, `send` can block the current thread: +With bounded (synchronous) channels, [`send()`] can block the current thread: ```rust,editable use std::sync::mpsc; @@ -32,12 +32,15 @@ fn main() {
-- Calling `send` will block the current thread until there is space in the +- Calling `send()` will block the current thread until there is space in the channel for the new message. The thread can be blocked indefinitely if there is nobody who reads from the channel. -- A call to `send` will abort with an error (that is why it returns `Result`) if - the channel is closed. A channel is closed when the receiver is dropped. +- A call to `send()` will abort with an error (that is why it returns `Result`) + if the channel is closed. A channel is closed when the receiver is dropped. - A bounded channel with a size of zero is called a "rendezvous channel". Every - send will block the current thread until another thread calls `recv`. + send will block the current thread until another thread calls [`recv()`].
+ +[`send()`]: https://doc.rust-lang.org/std/sync/mpsc/struct.SyncSender.html#method.send +[`recv()`]: https://doc.rust-lang.org/std/sync/mpsc/struct.Receiver.html#method.recv diff --git a/src/concurrency/channels/senders-receivers.md b/src/concurrency/channels/senders-receivers.md index c0ece357..2609196e 100644 --- a/src/concurrency/channels/senders-receivers.md +++ b/src/concurrency/channels/senders-receivers.md @@ -4,8 +4,8 @@ minutes: 9 # Senders and Receivers -Rust channels have two parts: a `Sender` and a `Receiver`. The two parts -are connected via the channel, but you only see the end-points. +Rust channels have two parts: a [`Sender`] and a [`Receiver`]. The two +parts are connected via the channel, but you only see the end-points. ```rust,editable use std::sync::mpsc; @@ -27,10 +27,16 @@ fn main() {
-- `mpsc` stands for Multi-Producer, Single-Consumer. `Sender` and `SyncSender` +- [`mpsc`] stands for Multi-Producer, Single-Consumer. `Sender` and `SyncSender` implement `Clone` (so you can make multiple producers) but `Receiver` does not. -- `send()` and `recv()` return `Result`. If they return `Err`, it means the +- [`send()`] and [`recv()`] return `Result`. If they return `Err`, it means the counterpart `Sender` or `Receiver` is dropped and the channel is closed.
+ +[`Sender`]: https://doc.rust-lang.org/std/sync/mpsc/struct.Sender.html +[`Receiver`]: https://doc.rust-lang.org/std/sync/mpsc/struct.Receiver.html +[`send()`]: https://doc.rust-lang.org/std/sync/mpsc/struct.Sender.html#method.send +[`recv()`]: https://doc.rust-lang.org/std/sync/mpsc/struct.Receiver.html#method.recv +[`mpsc`]: https://doc.rust-lang.org/std/sync/mpsc/index.html diff --git a/src/concurrency/channels/unbounded.md b/src/concurrency/channels/unbounded.md index c0664121..13008c84 100644 --- a/src/concurrency/channels/unbounded.md +++ b/src/concurrency/channels/unbounded.md @@ -4,7 +4,7 @@ minutes: 2 # Unbounded Channels -You get an unbounded and asynchronous channel with `mpsc::channel()`: +You get an unbounded and asynchronous channel with [`mpsc::channel()`]: ```rust,editable use std::sync::mpsc; @@ -29,3 +29,5 @@ fn main() { } } ``` + +[`mpsc::channel()`]: https://doc.rust-lang.org/std/sync/mpsc/fn.channel.html