cognitive-engineering-lab / rust-book

The Rust Programming Language: Experimental Edition
https://rust-book.cs.brown.edu
Other
593 stars 92 forks source link

Mis-use of "match" together with the locking (no concurrency while this is in use) #78

Closed savar closed 1 year ago

savar commented 1 year ago

https://github.com/cognitive-engineering-lab/rust-book/blob/c03097b089b214df802c0e628dfc7d87efb80bb2/listings/ch20-web-server/listing-20-24/src/lib.rs#LL73C13-L74C1

the final code uses let message = ...; match message { .. } which will still allow concurrency, but the "match" directly on the receiver.lock() will block the concurrency.

jlin-dorai commented 1 year ago

This has been fixed in the upstream repo. https://github.com/rust-lang/book/pull/3310

willcrichton commented 1 year ago

Yeah at some point I need to sync this with the upstream, which is going to be a bit painful..

willcrichton commented 1 year ago

Just merged upstream, so this should be fixed.