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 #4319

Closed
gretchenfrage opened this issue Dec 14, 2021 · 4 comments
Closed

Add blocking_recv method to oneshot::Receiver #4319

gretchenfrage opened this issue Dec 14, 2021 · 4 comments
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. E-easy Call for participation: Experience needed to fix: Easy / not much E-help-wanted Call for participation: Help is requested to fix this issue. M-sync Module: tokio/sync

Comments

@gretchenfrage
Copy link

Is your feature request related to a problem? Please describe.

I would like to be able to send a value into a oneshot, and receive it either in an async context or a blocking context, to create an API which supports in both blocking and async contexts.

Describe the solution you'd like

mpsc::Receiver and mpsc::UnboundedReceiver have blocking_recv methods. It would be nice to see an equivalent blocking_recv method added to oneshot::Receiver.

Describe alternatives you've considered

It would be interesting to instead simply expose the crate::future::block_on mechanism by which the existing blocking_recv methods are implemented, and have a concept of "this async function doesn't aaactually rely on tokio and thus can be used in a non-async context in a blocking way with that wrapper."

Additional context

It's for the winit-main crate if you're curious.

@gretchenfrage gretchenfrage added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Dec 14, 2021
@Darksonn Darksonn added the M-sync Module: tokio/sync label Dec 14, 2021
@Darksonn
Copy link
Contributor

I'm fine with adding this, though note that futures::executor::block_on is a solution that works today.

@Darksonn Darksonn added E-easy Call for participation: Experience needed to fix: Easy / not much E-help-wanted Call for participation: Help is requested to fix this issue. labels Dec 14, 2021
@Rustin170506
Copy link
Contributor

I am working on this.

@besok
Copy link

besok commented Jan 13, 2022

Apparently the issue should be closed

@Darksonn
Copy link
Contributor

Thanks.

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 C-feature-request Category: A feature request. E-easy Call for participation: Experience needed to fix: Easy / not much E-help-wanted Call for participation: Help is requested to fix this issue. M-sync Module: tokio/sync
Projects
None yet
Development

No branches or pull requests

4 participants