1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-20 14:31:15 +02:00

Add speaker notes to some concurrency pages (#2501)

Part of #1083.
This commit is contained in:
Dustin J. Mitchell 2024-12-06 09:03:03 -05:00 committed by GitHub
parent e0fa410f93
commit 380dc3c29c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 29 additions and 2 deletions

View File

@ -35,8 +35,8 @@ fn main() {
- 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.
- Like unbounded channels, a call to `send()` will abort with an error if the
channel is closed.
- 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()`].

View File

@ -31,3 +31,12 @@ fn main() {
```
[`mpsc::channel()`]: https://doc.rust-lang.org/std/sync/mpsc/fn.channel.html
<details>
- An unbounded channel will allocate as much space as is necessary to store
pending messages. The `send()` method will not block the calling thread.
- 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.
</details>

View File

@ -52,3 +52,12 @@ name = "dining-philosophers"
version = "0.1.0"
edition = "2021"
```
<details>
- Encourage students to focus first on implementing a solution that "mostly"
works.
- The deadlock in the simplest solution is a general concurrency problem and
highlights that Rust does not automatically prevent this sort of bug.
</details>

View File

@ -80,6 +80,15 @@ cargo run
`www.google.org` domain. Put an upper limit of 100 pages or so so that you
don't end up being blocked by the site.
<details>
- This is a complex exercise and intended to give students an opportunity to
work on a larger project than others. A success condition for this exercise is
to get stuck on some "real" issue and work through it with the support of
other students or the instructor.
</details>
[1]: https://docs.rs/reqwest/
[2]: https://docs.rs/scraper/
[3]: https://docs.rs/thiserror/