August 2018
Intermediate to advanced
380 pages
10h 2m
English
Remember when we discussed IO, we stressed the importance of asynchrony and non-blocking computations? Threads of the underlying operating system are scarce, and on a system with high load, you need to utilize them well. Blocking is not a wise utilization of the threads.
We have discussed that you should not invoke other threads from the current actor. The motivation for this is to prevent access to the mutable state of the current actor from more than one thread. We have discussed that whenever we need to process something, we schedule the processing as a message to the current actor.
Therefore, to enforce single-threaded processing, you might be tempted to block on a future from a message-handling logic, as follows:
Await.ready(future, ...