Using Typed Actors

The actors we saw so far accepted messages. We passed different types of messages, a String, tuples, case classes/custom messages, and so on. Yet, passing these messages felt quite different from the regular method calls we’re used to in everyday programming. Typed actors help bridge that gap by allowing us to make regular method calls and translating them to messages under the covers. Think of a typed actor as an active object, which runs in its own single lightweight event-driven thread, with an intercepting proxy to turn normal-looking method calls into asynchronous nonblocking messages.

Since typed actors convert regular method calls into messages under the covers, we can enjoy the benefits of static typing to the fullest ...

Get Programming Concurrency on the JVM now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.