Skip to content

SharedChan should not exist, it should be Chan + clone() #11351

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

Closed
alexcrichton opened this issue Jan 6, 2014 · 2 comments · Fixed by #11578
Closed

SharedChan should not exist, it should be Chan + clone() #11351

alexcrichton opened this issue Jan 6, 2014 · 2 comments · Fixed by #11578
Labels
A-concurrency Area: Concurrency
Milestone

Comments

@alexcrichton
Copy link
Member

I've come to not like having SharedChan. The best justification for me is that if you write an api which takes a channel as an argument, you must make a choice of which one to take (SharedChan vs Chan). Having made a decision one way or the other, you will always be wrong at least some of the time.

There's some trickiness with this:

  • Multiple senders should always be supported
  • It would be nice for one sender to still be a super-optimized use-case

This implies that a Chan should silently get promoted to a SharedChan on a clone(). I believe that this is possible, but I haven't thought through the specific workings in my head just yet.

Another benefit of doing this is reducing the cognitive burden when thinking about channels. We would then be able to fairly easily introduce a BlockingChan (with a better name) which blocks on sends as well as receives. The duality of blocking/nonblocking makes a lot more sense to me than the quadrality of nonblocking/shared nonblocking/blocking/shared blocking.

cc @brson, you made a comment to me awhile ago about doing this.

Nominating, this is backwards compat if we axe SharedChan

@jfager
Copy link
Contributor

jfager commented Jan 6, 2014

Can Chan be a trait? We used to have GenericChan, but that got axed in the last rewrite.

One use case example: https://github.com/jfager/d3cap/blob/master/multicast.rs#L67 - transparently wrapping sends in an enum the reader on the port end knows how to handle but that the sender shouldn't care about.

Not sure if this is sufficiently motivating, and would probably still need the non-blocking vs blocking distinction in the trait spec as the api would of course be different.

@pnkfelix
Copy link
Member

pnkfelix commented Jan 9, 2014

Accepted for 1.0, P-backcompat-libs

@bors bors closed this as completed in 11bc14d Feb 12, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Aug 24, 2023
Update version attribute for 1.72 lints

Roses are red,
Violets are blue,
Marker is alive,
and so are you!

---

![cat gif](https://cataas.com/cat/SbbeZwoC81vSTzBX)

cc: rust-lang/rust-clippy#10847 (comment)

---

I've also checked the `beta-nominated` label, the changelog should include everything :)

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-concurrency Area: Concurrency
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants