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: breaking changes to watch channel. #2172

Closed
carllerche opened this issue Jan 25, 2020 · 2 comments · Fixed by #2806
Closed

sync: breaking changes to watch channel. #2172

carllerche opened this issue Jan 25, 2020 · 2 comments · Fixed by #2806
Labels
A-tokio Area: The main tokio crate C-musing Category: musings about a better world M-sync Module: tokio/sync
Milestone

Comments

@carllerche
Copy link
Member

carllerche commented Jan 25, 2020

Tracks breaking changes to sync::watch

Now that broadcast exists, watch should be specialized to track a single value. The API should be made more consistent with other channels.

  • "sender shutdown" is out of scope and Receiver::recv() can just return T.
  • Sender should have send fn and not broadcast.
@carllerche carllerche added this to the v0.3 milestone Jan 25, 2020
@carllerche carllerche changed the title sync: watch::Receiver::recv() should not return Option sync: breaking changes to watch channel. Jan 26, 2020
@cdmistman
Copy link

cdmistman commented Mar 2, 2020

Are you suggesting that watch::Sender::send should be consuming like oneshot::Sender::send? In one of my projects, I'm using watch over broadcast because I only need the most recent value (I'm sending time-sensitive but loss-permissive signals from a 'master' task to several other tasks), but I can't use oneshot because I need to send multiple values.

I'd like to propose an alternative that won't break current uses of either channel type, but still allows each channel type to fill its niche: making oneshot be single-producer multi-consumer. This can be accomplished by adding oneshot::Sender::subscribe and/or impl<T> Clone for oneshot::Receiver<T>.

@Diggsey
Copy link
Contributor

Diggsey commented Mar 9, 2020

@donnellycolton I think you may have got the wrong idea?

One thing that would be useful is if there were convenience methods that made it act more like a Cell. For example, methods to access the value from the Sender side so you don't have to store an extra copy.

@taiki-e taiki-e added A-tokio Area: The main tokio crate M-sync Module: tokio/sync labels Jun 12, 2020
@Darksonn Darksonn added the C-musing Category: musings about a better world label Jul 25, 2020
blasrodri added a commit to blasrodri/tokio that referenced this issue Aug 31, 2020
carllerche pushed a commit that referenced this issue Sep 2, 2020
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-musing Category: musings about a better world M-sync Module: tokio/sync
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants