drepster
06/12/2025, 3:30 PMjarkko.poyry.metaplay
06/12/2025, 3:41 PMawaiting the response and cannot run the Ask Message Handler.
One trick to avoid this is to not await and instead run the Asks in background then continue when they complete, for example ContinueTaskOnActorContext(Task.WhenAll(...), task => { }, ...).drepster
06/12/2025, 4:13 PMjarkko.poyry.metaplay
06/12/2025, 4:46 PMawaiting essentially blocks the message handling for the actor, and that means the actor wont reply to any Asks.
So what this means is that if you await you can be sure no other message handler have been executed during this time and you can be sure the actor state is still the same as it was before you started awaiting.
A far fetched example of this is something like:
1. Check money
2. await someOperation
3. Do something with money
At step 3, you can be sure the assertion at 1 still holds.
Some actor frameworks like Swift Actors choose to allow any operations during awaits. This breaks the assertion at step 3 but avoids the risk of deadlock/timeout. Akka chooses one-at-a-time logic, which keeps local consistency, but can deadlock/timeout if you actors await each other.