Schedulers
Each reactor template can be used to start multiple reactor instances, and each reactor instance can be started with a different reactor scheduler. Different schedulers have different characteristics in terms of execution priority, frequency, latency, and throughput. In this section, we take a look at how to use a non-default scheduler, and how to define custom schedulers when necessary.
We start by defining a reactor that logs incoming events, reports every time it gets scheduled, and ends after being scheduled three times. We will use the sysEvents
stream of the reactor, which will be explained in the next section. For now, all you need to know is that the system event stream produces events when the reactor gets some execution time (that is, gets scheduled), and pauses its execution (that is, gets pre-empted).
The Logger
reactor is shown in the following snippet:
class Logger extends Reactor[String] { var count = 3 sysEvents onMatch { case ReactorScheduled => ...