Uh oh!
There was an error while loading. Please reload this page.
Explain non-dropped sender recv in docs - #80269
Conversation
rust-highfive
commented
Dec 21, 2020
r? @dtolnay (rust-highfive has picked a reviewer for you, use r? to override) |
Dylan-DPC-zz
commented
Feb 17, 2021
r? @KodrAus |
KodrAus
commented
Feb 19, 2021
Thanks for the PR @pickfire! That original wording is a little unclear that it won’t unblock unless all senders are dropped, isn’t it. Maybe we could just clarify it a bit more there and avoid sprinkling too many more warnings around? |
pickfire
commented
Feb 19, 2021
Where is that? I can't seemed to find it. I did try finding that but I couldn't find anything so I wrote this PR.
I searched though the file but I can't see it and tried reading the docs again. Can you please point me to the exact line and word you are talking about? |
KodrAus
commented
Feb 21, 2021
@pickfire That's in the docs for the Having another look through our docs, maybe the section on disconnection in the What do you think? |
Where? I read that part, I had even modified that part in this pull request and yet I didn't saw it. I think this part is quite blur and did not mention the word "drop". If you can point me the exact part out maybe I can switch the keywords to "drop" so it is simpler to understand. Would that be better?
Adding it to both cc @jyn514 for https://github.com/rust-lang/rust/pull/81833/files#r575693721 |
jyn514
commented
Feb 22, 2021
@jyn514 I'm guessing it was because of the conversation on a review comment there that was subsequently resolved (and thus is remarkably hard to link to directly: |
pickfire
commented
Feb 24, 2021
@jyn514 Do you see the
"it's possible for more data to be sent." but I think not everyone can easily relate that as "all senders have been dropped". |
jyn514
commented
Feb 24, 2021
Personally, I don't think any documentation changes would have made me not ask questions in #81833 - I'm very unfamiliar with actor-style programming and I wouldn't have thought to look at the API reference for a conceptual overview. I don't think this is a bad change, I just don't have any feedback to give. |
the8472
commented
Mar 12, 2021
Disconnection itself is explained in prose, which code patterns arise from that isn't reflected in the examples since they only use single steps or counted loops. The importance of correct ordering in the |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
pickfire
commented
Mar 14, 2021
I think it would be better if we have an example of using |
the8472
commented
Mar 14, 2021
I'm not sure how that's different from what I have said, for |
pickfire
commented
Mar 15, 2021
I added an example based on tokio drop to show the cases we need drop. |
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
JohnCSimon
commented
May 23, 2021
ping from triage: |
pickfire
commented
May 24, 2021
Yes, I have addressed the changes requested. |
JohnTitor
commented
Jun 11, 2021
@pickfire Could you squash commits into one? I'll r=josh once it's done as per #80269 (comment). |
Original senders that are still hanging around could cause Receiver::recv to not block since this is a potential footgun for beginners, clarify more on this in the docs for readers to be aware about it. Fix minor tidbits in sender recv doc Co-authored-by: Dylan DPC <dylan.dpc@gmail.com> Add example for unbounded receive loops in doc Show the drop(tx) pattern, based on tokio docs https://tokio-rs.github.io/tokio/doc/tokio/sync/index.html Fix example code for drop sender recv Fix wording in sender docs Co-authored-by: Josh Triplett <josh@joshtriplett.org>
pickfire
commented
Jun 12, 2021
Done |
JohnTitor
commented
Jun 12, 2021
Looks like you forgot to push it? |
pickfire
commented
Jun 14, 2021
Ah, thanks. I missed that. |
Thanks! @bors r=joshtriplett rollup |
JohnTitor
commented
Jun 15, 2021
Hmm, bors didn't catch it? |
Mark-Simulacrum
commented
Jun 15, 2021
@bors r=joshtriplett rollup |
bors
commented
Jun 15, 2021
📌 Commit 0f3c7d1 has been approved by |
Rollup of 10 pull requests Successful merges: - rust-lang#80269 (Explain non-dropped sender recv in docs) - rust-lang#82179 (Add functions `Duration::try_from_secs_{f32, f64}`) - rust-lang#85608 (Stabilize `ops::ControlFlow` (just the type)) - rust-lang#85792 (Refactor windows sockets impl methods) - rust-lang#86220 (Improve maybe_uninit_extra docs) - rust-lang#86277 (Remove must_use from ALLOWED_ATTRIBUTES) - rust-lang#86285 (:arrow_up: rust-analyzer) - rust-lang#86294 (Stabilize {std, core}::prelude::rust_*.) - rust-lang#86306 (Add mailmap entries for myself) - rust-lang#86314 (Remove trailing triple backticks in `mut_keyword` docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Explain non-dropped sender recv in docs Original senders that are still hanging around could cause Receiver::recv to not block since this is a potential footgun for beginners, clarify more on this in the docs for readers to be aware about it. Maybe it would be better to show an example of the pattern where `drop(tx)` is used when it is being cloned multiple times? Although I have seen it in quite a few articles but I am surprised that this part is not very clear with the current words without careful reading. > If the corresponding Sender has disconnected, or it disconnects while this call is blocking, this call will wake up and return Err to indicate that no more messages can ever be received on this channel. However, since channels are buffered, messages sent before the disconnect will still be properly received. Some words there may seemed similar if I carefully read and relate it but if I am new, I probably does not know "drop" makes it "disconnected". So I mention the words "drop" and "alive" to make it more relatable to lifetime.

Original senders that are still hanging around could cause
Receiver::recv to not block since this is a potential footgun
for beginners, clarify more on this in the docs for readers to
be aware about it.
Maybe it would be better to show an example of the pattern where
drop(tx)is used when it is being cloned multiple times? Although I have seen it in quite a few articles but I am surprised that this part is not very clear with the current words without careful reading.Some words there may seemed similar if I carefully read and relate it but if I am new, I probably does not know "drop" makes it "disconnected". So I mention the words "drop" and "alive" to make it more relatable to lifetime.