As the book warns just in the section prior to the one linked above, using a MutexGuard in a match expression prevents mutex from being unlocked and the threads from running in parallel.
Suggested fix:
+ let message = receiver.lock().unwrap().recv();
+
- match receiver.lock().unwrap().recv() {
+ match message {
main
branch to see if this has already been fixedURL to the section(s) of the book with this problem:
https://github.com/cognitive-engineering-lab/rust-book/blob/ac7e98be8fdbd0ee81f2eeb049754a2b403631e8/listings/ch20-web-server/listing-20-24/src/lib.rs#L73
Description of the problem:
As the book warns just in the section prior to the one linked above, using a
MutexGuard
in a match expression prevents mutex from being unlocked and the threads from running in parallel.Suggested fix: