Introduction
In the last chapter, we learned how to route messages to actors, and in this chapter, we will learn about futures.
Futures are used to perform an operation in other threads for concurrency and parallel execution. They contain the result of the concurrent operation and can be accessed synchronously, by blocking the current thread of execution, or asynchronously, (non-blocking) by handling the callback on a future.
Futures require ExecutionContext
, which is backed by a thread pool to execute callbacks and other operations.
So, more or less, futures are used to execute operations on other threads concurrently.