Document blocking guarantees for std::sync#158679
Conversation
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @clarfonthey (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
| //! | ||
| //! This is only of note to platforms which disallow blocking, such as multithreaded WebAssembly on the main thread. | ||
| //! None of the implementations in `std::sync` are guaranteed to be (or remain) non-blocking in this regard. | ||
| // Discussion on blocking: https://github.com/rust-lang/rust/issues/157728 |
There was a problem hiding this comment.
Not 100% sure that linking a GitHub issue here is best, since we'd rather any new issues be brought up separately than just constantly going back to an issue that would eventually be closed. Is there any other information in that thread you feel might be useful to include here, since from what I can see, this should cover everything?
There was a problem hiding this comment.
Yeah, that's fair. I thought it would be good to have a link back to the original decision (for posterity, I guess) but now that I think of it one could just find the issue through git blame...
There was a problem hiding this comment.
It's mostly just, I think that folks really wanting to dig into history can do that already, and we should be confident in changes we make unless we explicitly know they're temporary.
|
LGTM minus one minor comment on linking the GitHub issue, since this would close that issue. |
1a54156 to
81a18e7
Compare
|
@bors r+ rollup |
…arantees, r=clarfonthey Document blocking guarantees for `std::sync` Per rust-lang#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#157728
Per #157728, this PR documents how exactly functions/methods in
std::mpsc(andmpmc) block.Copied from the issue:
(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 #157728