-
Notifications
You must be signed in to change notification settings - Fork 950
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
StreamMuxer
methods should take &mut self
#1556
Comments
We discussed this a while ago and I agree with the idea, but this is a hypothetical change and given the complexity it's probably not going to happen any time soon. |
What would need to be done to implement this? |
(assuming we don't want to simply wrap Having If we can no longer have an implementation of Alternatively, we could keep an object that implements |
It's one of these issues where yes, performance is slightly degraded, but doing things in a true zero-cost way would considerably increase the complexity of the code. |
What would that zero-cost way be? As is so often the case, callbacks are zero-cost, but they are not a fun programming paradigm. One alternative is to drop the requirement that |
Expecting that a |
It is also worth noting that, in light of |
Unfortunately, since And if, within that Again that's a deficiency in Rust. For example, in this case, the future could technically be let fut = async move {
let ptr = std::rc::Rc::new(5);
let ptr2 = ptr.clone();
}; But in this example, it can't: let ptr = std::rc::Rc::new(5);
let fut = async move {
let ptr2 = ptr.clone();
}; But Rust isn't smart enough to figure that out (and it would indeed probably be quite complicated to figure that out). |
@tomaka what if we used a local executor that never migrated futures between threads? |
Sadly, our uses of |
The standard Linux RDMA library, Furthermore, calling Closing as will not fix. |
As a heads-up, this is now happening: #2765 |
Currently,
StreamMuxer
is expected to beSync
, and all of its methods take&self
. This forces implementations to do costly locking internally.Since most uses of
StreamMuxer
use a single task for the entire connection, this overhead can be avoided in the common case. In the rare case where this does not hold, messages can be passed asynchronously.The text was updated successfully, but these errors were encountered: