Lumiera
0.pre.03
»edit your freedom«
|
#include "common/subsystem-runner.hpp"
Implementation helper for managing execution of a collection of subsystems, which may depend on one another and execute in parallel.
Properties of the subsystems are available through Subsys object refs, which act as handle. In this context, »Subsystem« is an abstraction and doesn't necessarily correspond to a single component, interface or plugin. It may well be a complete layer of the application (e.g. the GUI).
The SubsystemRunner is to be configured with a lumiera::Option object first. Then, primary subsystems are provided for eventual startup, which may depend on conditions defined by the subsystem. When it turns out (by investigating the options) that a Subsystem is actually to be pulled up, all of its prerequisite subsystems shall be started beforehand. Problems while starting may result in throwing an exception, which is not handled here and aborts the whole operation. On startup, a callback signal slot is reserved for each subsystem to notify the SubsystemRunner on termination. It is the liability of the subsystems to ensure this callback functor is activated reliably, irrespective of what actually causes the termination; failure to do so may deadlock the whole System.
Usually, the startup process is conducted from one (main) thread, which enters the blocking wait after starting the subsystems. Awakened by some termination signal from one of the subsystems, termination of any remaining subsystems will be triggered. The #wait() function returns after shutdown of all subsystems, signalling an emergency situation with its return value. In this context, emergency is defined by encountering an top-level exception in any Subsystem, reported by a non-empty error string in the sigTerm handler. An emergency thus jeopardises the ability to wind-down the all parts of the application reliably.
Definition at line 109 of file subsystem-runner.hpp.
Public Member Functions | |
SubsystemRunner (Option &opts) | |
void | maybeRun (Subsys &susy) |
void | shutdownAll () |
void | triggerEmergency (bool cond) |
bool | wait () |
Private Member Functions | |
bool | allDead () |
bool | isEmergency () |
void | sigTerm (Subsys *susy, string *problem) |
void | triggerStartup (Subsys *susy) |
Private Attributes | |
volatile bool | emergency_ |
Option & | opts_ |
vector< Subsys * > | running_ |
Additional Inherited Members | |
Static Public Member Functions inherited from Sync< CONF > | |
static Monitor & | getMonitor (Sync const *forThis) |
|
inlineprivate |
problem | called from subsystem on termination |
Definition at line 195 of file subsystem-runner.hpp.