mirror of
https://github.com/rust-lang/rust.git
synced 2026-07-07 08:17:56 -04:00
f2b7994a66
Document blocking guarantees for `std::sync` Per rust-lang/rust#157728, this PR documents how exactly functions/methods in `std::mpsc` (and `mpmc`) block. Copied from the issue: > For the wasm part of this specifically, yes, using a mutex anywhere is basically forbidden on the main thread in browsers. Personally I don't think it's reasonable to expect the standard library to use zero mutexes on wasm and make absolutely everything lock-free. This is a consequence of browsers and not something Rust can "just" fix. Basically I would not recommend changing the implementation and instead leaving it as-is. I'll note that there's a long and storied history of blocking-the-main-thread-with-wasm-threads in the browser, and I'm not putting in all the context here. > > \- alexcrichton (P.S. documentation seems to be line wrapped but doesn't have a consistent wrapping width? I tried to match the surrounding style as best as I could; let me know if there's something better I should've done) Fixes rust-lang/rust#157728