How to do asynchronous communication in lattice mode
Closed this issue · 3 comments
Currently one can only do synchronous communication using call
function. I was wondering if there is plan to provide asynchronous call feature. The use-case could be chain of actors's call such as A--> B --> C --> D ....--> Z
. Actor A
will be blocked till actor Z
returns in case of a synchronous call.
There's a couple of types of functionality illustrated at the same time with your example. If A is blocked, and its an actor, then this is a synchronous call. Actors are single-threaded and as a result they cannot spawn a child thread or execution worker of any kind and asynchronously wait for work to complete. These synchronous calls also keep the actor's inbound work queue from moving. If A makes an asynchronous cast
to B, then A can safely return to idle state and await an incoming message from anywhere, which could be a direct invocation from actor Z, or simply a message published to a topic, etc. But user code will not appear to be synchronous - you won't be able to have code that looks like await call(B)
I do have plans for an asynchronous actor call function, described here in this newly created issue - #72
So, while asynchronous calls are planned, they may not necessarily be what you're looking for in order to support a chain of blocking calls.
Thanks! I was looking for the async call
feature. Actor A
can do some other useful tasks while waiting for the response.
Yep, then you'll want to watch #72