https://kotlinlang.org logo
Title
c

coder82

08/13/2019, 10:32 AM
Another idea which pops in my mind is to use the actor model, send methods and use reflection to invoke them inside the worker, but all in all, if wonder if my thoughts are sane and if I am taking the right path. I like more the idea of submitting a task rather than a message with a "type" which leads to an implementation called by the worker @gildor @elizarov
e

elizarov

08/13/2019, 11:55 AM
There is no need for reflection. Use the lambda capture, Luke.
E.g.:
class MyActor {
    fun operation(params) = act { ... code here ... }
}
Where
act
is a higher-order function that captures the corresponding code and executes it in the actor’s context.
👍 1
c

coder82

08/14/2019, 7:37 AM
So do you suggest passing the whole lambda through the channel? I didn't quite get it.
e

elizarov

08/14/2019, 7:38 AM
Yes
👍 1