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

Add blocking_recv method to oneshot::Receiver #4334

Merged
merged 3 commits into from
Jan 10, 2022

Conversation

0xd34d10cc
Copy link
Contributor

Motivation

See #4319

Solution

The solution is same as in mpsc channels, except that method receiver is self instead of &mut self.

@github-actions github-actions bot added the R-loom Run loom tests on this PR label Dec 21, 2021
@Darksonn Darksonn added A-tokio Area: The main tokio crate M-sync Module: tokio/sync and removed R-loom Run loom tests on this PR labels Dec 21, 2021
Comment on lines 1043 to 1045
pub fn blocking_recv(self) -> Option<T> {
crate::future::block_on(self).ok()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be using the RecvError like .await does for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wouldn't that be inconsistent with mpsc::Receiver::blocking_recv and mpsc::UnboundedReceiver::blocking_recv? Both of them return Option.

…s enabled (future::block_on is exported only if it is enabled, but sync module is compiled in any case for use within tokio)
@github-actions github-actions bot added the R-loom Run loom tests on this PR label Dec 21, 2021
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

Thanks.

@Darksonn Darksonn merged commit bcb968a into tokio-rs:master Jan 10, 2022
@0xd34d10cc 0xd34d10cc deleted the oneshot_blocking_recv branch January 10, 2022 15:15
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 R-loom Run loom tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants