Details
-
Bug
-
Status: Resolved
-
Resolution: Done
-
Helium
-
None
-
None
-
Operating System: All
Platform: All
-
1534
Description
The ActorContext#executeRemoteOperation method sends a message to an Actor and blocks waiting for the result. There are some places where we need to block but other places where we don't need to.
Eg, in TransactionContextImpl#readData, it needs to return a ListenableFuture back to the caller so it submits a Callable task to an executor which just calls ActorContext#executeRemoteOperation and waits for the result. It would be ideal if we could make this completely async and avoid the overhead of submitting a task and creating a thread that just blocks.
ActorContext#executeRemoteOperation calls the akka 'ask' method to send the message which returns a scala Future. The Future class has onSuccess and onFailure methods to register callbacks and, in reading the scala docs, these methods are non-blocking. This is very similar to guava's ListenableFuture. We can create a guava SettableFuture to return to the caller and set the result via onSuccess/onFailure asynchronously.