4.5 Finalising Signals

The signalFinalize method provided by the Signal interface is designed for situations where a service is being shut down and all subscribed signalable objects need to be notified. It issues a standard signal notification to all subscribed signalable objects and then automatically unsubscribes them from the signal. By way of example, this is the mechanism used by the reactor to issue the reactor shutdown signal.

One thing to consider when using finalising signals is that there is no pre-defined way of notifying the signal handlers of the difference between standard and finalising signal callbacks. In some cases - such as the reactor shutdown signal - a signal callback will only be issued once and this can be implicitly interpreted as a finalising signal. In other situations it will be necessary to encode the fact that the signal is a finalising signal as part of the signal data parameter. A common approach is to use the passing of a null parameter here as an indication of a finalising signal.