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

Description

A simulated "Lumiera Subsystem".

It is capable of starting a separate thread, which may terminate regularly after a random time, or may fail in various ways. The behaviour is controlled by a number of definitions, given at construction in logic predicate notation.

Definition at line 102 of file subsystem-runner-test.cpp.

Public Member Functions

 MockSys (Literal id, Literal spec)
 
bool didRun () const
 
 operator string () const
 a human readable name
 
- Public Member Functions inherited from Subsys
Subsysdepends (Subsys &prereq)
 define a dependency to another Subsys required for running this subsystem
 
const std::vector< Subsys * > getPrerequisites ()
 
bool isRunning () noexcept
 

Private Member Functions

bool checkRunningState () noexcept override
 whether this subsystem is actually operational. More...
 
void run (Subsys::SigTerm termination)
 executes in a separate thread and simulates a "running" subsystem. More...
 
bool shouldStart (lumiera::Option &) override
 query application option state to determine if this subsystem should be activated. More...
 
bool shouldTerminate ()
 
bool start (lumiera::Option &, Subsys::SigTerm termination) override
 attempt to bring up this subsystem up. More...
 
void triggerShutdown () noexcept override
 initiate termination of this subsystem. More...
 

Private Attributes

lib::SyncBarrier barrier_ {}
 
atomic_bool didRun_ {false}
 
const string id_
 
atomic_bool isUp_ {false}
 
int running_duration_ {0}
 
const string spec_
 
atomic_bool started_ {false}
 
atomic_bool termRequest_ {false}
 
unique_ptr< Threadthread_ {}
 

Additional Inherited Members

- Public Types inherited from Subsys
typedef function< void(string *)> SigTerm
 

Member Function Documentation

◆ shouldStart()

bool shouldStart ( lumiera::Option )
inlineoverrideprivatevirtual

query application option state to determine if this subsystem should be activated.

Note
even if not started explicitly, it could still be started as prerequisite of another one

Implements Subsys.

Definition at line 118 of file subsystem-runner-test.cpp.

◆ start()

bool start ( lumiera::Option options,
Subsys::SigTerm   
)
inlineoverrideprivatevirtual

attempt to bring up this subsystem up.

On return, the subsystem must be operational, according to checkRunningState(). Failure to start up usually terminates the whole application. When this subsystem ceases to work, it must ensure to activate the given callback signal.

Parameters
optionsmay be influencing the operation mode
SigTermto be signalled by the subsystem.
Warning
termination must be signalled reliably.
Returns
true if actually started.

Implements Subsys.

Definition at line 128 of file subsystem-runner-test.cpp.

References cStr().

+ Here is the call graph for this function:

◆ triggerShutdown()

void triggerShutdown ( )
inlineoverrideprivatevirtualnoexcept

initiate termination of this subsystem.

This trigger may be called repeatedly any time... When the subsystem actually has terminated, the SigTerm passed to start must be invoked.

Note
called within a locked context (barrier)
Warning
must not block nor throw.

Implements Subsys.

Definition at line 156 of file subsystem-runner-test.cpp.

References cStr().

+ Here is the call graph for this function:

◆ checkRunningState()

bool checkRunningState ( )
inlineoverrideprivatevirtualnoexcept

whether this subsystem is actually operational.

When returning false here, the application may terminate at any point without further notice Note further, that a subsystem must not be in running state when signalling termination.

Implements Subsys.

Definition at line 165 of file subsystem-runner-test.cpp.

◆ run()

void run ( Subsys::SigTerm  termination)
inlineprivate

executes in a separate thread and simulates a "running" subsystem.

Behaviour determined by run(XX) spec:

  • run(true) : start, run, terminate normally
  • run(throw): start, run, signal abnormal termination
  • run(fail) : set didRun_, but abort, never enter running state
  • run(false): just handshake, but then abort without further action

Definition at line 181 of file subsystem-runner-test.cpp.

+ Inheritance diagram for MockSys:
+ Collaboration diagram for MockSys:

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