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
spawnmethod, the reactor is scheduled for execution. Its constructor is started asynchronously, and immediately after that, aReactorStartedevent is dispatched.Then, whenever the reactor gets execution time, the
ReactorScheduledevent gets dispatched. After that, events get dispatched on normal event streams.When the scheduling system decides to pre-empt the reactor, the
ReactorPreemptedevent 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...