Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: add more oneshot examples #4153

Merged
merged 3 commits into from
Oct 8, 2021
Merged

sync: add more oneshot examples #4153

merged 3 commits into from
Oct 8, 2021

Conversation

Darksonn
Copy link
Contributor

@Darksonn Darksonn commented Oct 5, 2021

Some examples are duplicated both on the module and Sender or Receiver structs to make them more easily discoverable.

@Darksonn Darksonn added T-docs Topic: documentation A-tokio Area: The main tokio crate M-sync Module: tokio/sync labels Oct 5, 2021
Copy link
Contributor

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Not a real reviewer here, but I try to pay it back a bit)
This looks sane to me!

tokio/src/sync/oneshot.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Noah-Kennedy Noah-Kennedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great to me!

@Darksonn Darksonn merged commit f0cb360 into master Oct 8, 2021
@Darksonn Darksonn deleted the oneshot-examples branch October 8, 2021 06:52
oliver-giersch pushed a commit to oliver-giersch/tokio that referenced this pull request Oct 28, 2021
/// ```
///
/// To use a `Sender` from a destructor, put it in an [`Option`] and call
/// [`Option::take`].
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I ask why it's recommended to wrap Sender in an Option here? I can't seem to find a rationale!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you try removing the option, it should quickly become clear: it wont compile without it. Calling send on an oneshot channel destroys the sender.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-sync Module: tokio/sync T-docs Topic: documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants