Reactor lifecycle
Every reactor goes through a certain set of stages during its lifetime, which are jointly called a reactor lifecycle. When the reactor enters a specific stage, it emits a lifecycle event. These lifecycle events are dispatched on a special daemon event stream called sysEvents
. Every reactor is created with this special event stream.
The reactor lifecycle can be summarized as follows:
After calling the
spawn
method, the reactor is scheduled for execution. Its constructor is started asynchronously, and immediately after that, aReactorStarted
event is dispatched.Then, whenever the reactor gets execution time, the
ReactorScheduled
event gets dispatched. After that, events get dispatched on normal event streams.When the scheduling system decides to pre-empt the reactor, the
ReactorPreempted
event is dispatched. This scheduling cycle can be repeated any number of times.Eventually, the reactor terminates, either by normal execution or exceptionally. If a user code exception terminates...