Lumiera  0.pre.03
»edit your freedom«
SubsystemRunner Class Reference

#include "common/subsystem-runner.hpp"

Description

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).

Protocol of operation

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.

Todo:
2018 this component works well but could be (re)written in a cleaner way ////////////////////////TICKET #1177
See also
lumiera::AppState
lumiera::Subsys
main.cpp

Definition at line 118 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_
 
Optionopts_
 
vector< Subsys * > running_
 

Additional Inherited Members

- Static Public Member Functions inherited from Sync< CONF >
static MonitorgetMonitor (Sync const *forThis)
 

Member Function Documentation

◆ sigTerm()

void sigTerm ( Subsys susy,
string *  problem 
)
inlineprivate
Parameters
problemcalled from subsystem on termination

Definition at line 204 of file subsystem-runner.hpp.

+ Inheritance diagram for SubsystemRunner:
+ Collaboration diagram for SubsystemRunner:

The documentation for this class was generated from the following file: