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

watch::Receiver and broadcast::Receiver cannot be composed #3123

Closed
vojtechkral opened this issue Nov 10, 2020 · 2 comments
Closed

watch::Receiver and broadcast::Receiver cannot be composed #3123

vojtechkral opened this issue Nov 10, 2020 · 2 comments
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-sync Module: tokio/sync

Comments

@vojtechkral
Copy link
Contributor

vojtechkral commented Nov 10, 2020

Is your feature request related to a problem? Please describe.
In our codebase we have some Futures implemented on top of watch::Receiver. This works fine in 0.2 as watch::Receiver implemented Stream, which could be delegated to.
But now there's only one async fn (changed()) which can't be polled over in a Future implementation (unless the resulting opaque future is boxed up and stored, which seems hacky).

Describe the solution you'd like
Not sure, maybe reinstate the Stream implementation? Or, in fact, maybe just a function to register a Context would suffice... Doesn't really matter to me as long as the API can be used from Future::poll().

Describe alternatives you've considered
I looked if I could use broadcast instead, but in fact there's the same problem, it also only exposes opaque Future/Stream types.

@vojtechkral vojtechkral added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Nov 10, 2020
@Darksonn Darksonn added the M-sync Module: tokio/sync label Nov 11, 2020
@Darksonn
Copy link
Contributor

There is a good reason related to the internal implementation for this, however it would be possible to expose an into_stream for Watch like there is for broadcast, and it would be possible to make those non-opaque types. The streams would be !Unpin due to the internal implementation details I mentioned.

One option is to add a Stream convenience like we're doing with mpsc sender in #3105.

@theduke
Copy link
Contributor

theduke commented May 18, 2021

It seems like this is now implemented with the WatchStream wrapper, correct?

If so this could be closed.

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. M-sync Module: tokio/sync
Projects
None yet
Development

No branches or pull requests

3 participants