-
Notifications
You must be signed in to change notification settings - Fork 29
Take advantage of the separation between mutable and immutable subsystem calls #131
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
Comments
Good afternoon @iljakuklic, While checking this issue I don't fully understand why "call_mut" is actually needed. I have the impression that all the Actions, and their CallResult responses, could be done properly throughout the UnboundedChannel only using the immutable methods (System::call) but I might be missing some details. May kindly share a couple of use cases where "call_mut" and "call" is needed and why please ? That will help me to understand it better. Thanks in advance |
In The idea behind this issue is that when using shared references (
You can have a look in
Hope this helps. |
Morning @iljakuklic and thanks for the reply. I understand it but I have the impression that we could never achieve a parallel execution as there is a tokio::unbounded mpsc channel, meaning that all messages are enqueued and only processed by one single receiver, i.e. the messages can only be processed on after the other, sequentially. I agree that there should be the synchronization mechanism that you mentioned in your previous comment. In order to achieve parallel execution I think there might be a pool of threads that share a reference to the Subsystem, wrapped in a RwLock, and we should use a mpmc approach with either flume or async_channel. That thread-subsystem pool will act as a consumers pool. Feel free to correct me if needed or disagree. |
Yes, the implementation would have to change substantially to do it.
Thank you for researching this.
To be perfectly honest, I would consider tackling this issue at this point a premature optimisation:
|
Thanks for the reply @iljakuklic. I agree with your points and for now this represents a premature optimization. |
We have two methods to call functions on subsystems:
Subsystem::call
andSubsystem::call_mut
. These expose the subsystem internal state as an immutable and mutable reference, respectively. Currently, thecall
method just delegates to thecall_mut
method. A separate implementation forcall
could be provided that takes the advantage of the immutability to execute multiple calls simultaneously.The text was updated successfully, but these errors were encountered: