Reactors

As we learned previously, event streams always propagate events on a single thread. This is useful from the standpoint of program comprehension, but we still need a way to express concurrency in our programs. In this section, we will see how to achieve concurrency by using entities called reactors.

A reactor is the basic unit of concurrency. While actors receive messages, we will adopt the terminology in which reactors receive events, in order to disambiguate. However, while an actor a in particular state has only a single point where it can receive a message, namely, the receive statement, a reactor can receive an event from many different sources at any time. Despite this flexibility, one reactor will always process, at most, one event ...

Get Learning Concurrent Programming in Scala - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.