mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-03-21 06:36:31 +02:00
parent
e0fa410f93
commit
380dc3c29c
@ -35,8 +35,8 @@ 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
|
channel for the new message. The thread can be blocked indefinitely if there
|
||||||
is nobody who reads from the channel.
|
is nobody who reads from the channel.
|
||||||
- A call to `send()` will abort with an error (that is why it returns `Result`)
|
- Like unbounded channels, a call to `send()` will abort with an error if the
|
||||||
if the channel is closed. A channel is closed when the receiver is dropped.
|
channel is closed.
|
||||||
- A bounded channel with a size of zero is called a "rendezvous channel". Every
|
- 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()`].
|
||||||
|
|
||||||
|
@ -31,3 +31,12 @@ fn main() {
|
|||||||
```
|
```
|
||||||
|
|
||||||
[`mpsc::channel()`]: https://doc.rust-lang.org/std/sync/mpsc/fn.channel.html
|
[`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>
|
||||||
|
@ -52,3 +52,12 @@ name = "dining-philosophers"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
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>
|
||||||
|
@ -80,6 +80,15 @@ cargo run
|
|||||||
`www.google.org` domain. Put an upper limit of 100 pages or so so that you
|
`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.
|
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/
|
[1]: https://docs.rs/reqwest/
|
||||||
[2]: https://docs.rs/scraper/
|
[2]: https://docs.rs/scraper/
|
||||||
[3]: https://docs.rs/thiserror/
|
[3]: https://docs.rs/thiserror/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user