Listing 4.4 provides the simplest possible demonstration of signal event handling. The reactor provides a special signal which is used to indicate that the reactor is shutting down - and it is possible to obtain a handle on this signal via the getReactorShutdownSignal method on the Reactor interface. This call returns a reference to the signal event object which is responsible for propagating the reactor's shutdown signal notification.
Signal event objects implement the Signal interface which allows signalable event handlers to be attached and removed from the signal. In this example, a signalable callback is attached to the reactor's shutdown signal using the subscribe method. When the reactor shutdown signal is triggered, it is then propagated to all subscribed signalable event handlers. In this case there is only a single handler, which prints a reactor shutdown message to the console. The full source code for the example shown in Listing 4.4 is provided in the signal examples package as ReactorShutdownSignal.