-
Notifications
You must be signed in to change notification settings - Fork 631
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
Consider replacing channels #1907
Comments
Alternatively:
|
|
Yes, these are valid approaches to making channels more replaceable down the road. But my issue is:
There is an associated question/implicit assumption: Are the channels necessary part of the futures crate ? I'd say yes, because I see futures crate as a first one I include inside a project that utilizes std::futures + async await. And a channel is an abstraction that is invaluable. So I will go from this assumption forward. After taking in these assumptions, the logical question is: With what ? And there are several possible answers, 2 of which are in my original post |
The only internal dependency on channels is the oneshot channel being used for the I agree that it makes sense for |
For some context, I contributed the original mpsc implementation in futures-rs many years ago. It was always intended to be a "first pass". Since then, I wrote the "next generation" channel as part of Even if |
If you are interested in another approach on implementing channels, you might want to take a look at (or even use) the futures-intrusive implementations. Those have the advantage of being truly bounded (even unbuffered/rendezvous is possible), are MPMC and don’t require extra resources per using task. They are also somewhat simpler (less atomic magic). An advantage that wasn’t yet mentioned here is that it doesn’t leak Wakers (which can lead to a memory leak) when tasks are cancelled. Performance aspect depends on the use case. I did some benchmarking and included ones in the repo. I looks to me like it rather performs better than worse for typical applications, but in doubt everyone can do their own evaluation. |
Current implementation can be traced back to the standard library. It worked great for a while, but it seems, it would be wise to replace this aging code with something new while we still have a chance, before stabilizing 0.3.
Issues with current implementation:
Send + 'static
is cloning the sender, and using a cloned variant. This basically makes bounded channels unbounded, and thus useless.try_
methods #861Replacements:
Design of async channels async-rs/async-std#212
Motivation
The futures-rs crate is backbone of the async ecosystem. The proliferation of alternative channel implementations signifies that this aspect of the library no longer serves the needs of the community. In order to resolve these issues, a new implementation of channels is needed.
There is one extremely good implementation of channels in the wild, which is in consideration for inclusion in the standard library, and the futures library is getting left behind by these improvements.
The text was updated successfully, but these errors were encountered: