|
|
Owns every start and stop of one application - nothing else may launch or signal it. More...
#include <ArmarXCore/util/ScenarioManagerCommon/executor/ApplicationLifecycle.h>
Inheritance diagram for ApplicationLifecycle:Public Member Functions | |
| ApplicationLifecycle (Data_Structure::ApplicationInstancePtr application, StatusManager statusManager) | |
| bool | busy () const |
| Data_Structure::Intent | effectiveIntent () const |
| void | request (Data_Structure::Intent intent, const ApplicationStarterPtr &starter, const StopStrategyPtr &stopStrategy, const std::string &commandLineParameters="", bool printOnly=false) |
| Requests that the application be started, stopped or restarted, superseding any intent that has not been executed yet. | |
| void | wait () |
| Blocks until nothing is requested or running any more. | |
Owns every start and stop of one application - nothing else may launch or signal it.
Callers do not execute operations, they request an intent. Requesting an intent supersedes any intent that has not been carried out yet, so pressing Start, Stop, Start, Stop in quick succession runs at most one superfluous operation and always ends in the state the last press asked for ("last intent wins"). Nothing is ever refused and nothing is ever aborted halfway: a fork/exec or a wait for a process to die always runs to completion, and a newer intent is only picked up at a phase boundary.
The reason this class exists is that lifecycle state used to be owned by three classes at once - the Executor set a "write block" flag, the starter cleared it in a scope guard and the stop strategy cleared it as well. A restart's internal stop therefore released the flag that the restart itself still needed, which let a concurrent start launch a second process that the ScenarioManager then lost track of.
Threading: a worker thread is spawned on demand and exits as soon as there is nothing left to do, so only applications that are currently being operated on cost a thread. The worker holds a shared_ptr to this object and to the application, so neither can be destroyed underneath it.
Definition at line 81 of file ApplicationLifecycle.h.
| ApplicationLifecycle | ( | Data_Structure::ApplicationInstancePtr | application, |
| StatusManager | statusManager ) |
Definition at line 51 of file ApplicationLifecycle.cpp.
| bool busy | ( | ) | const |
Definition at line 97 of file ApplicationLifecycle.cpp.
Here is the call graph for this function:| Intent effectiveIntent | ( | ) | const |
Definition at line 90 of file ApplicationLifecycle.cpp.
Here is the caller graph for this function:| void request | ( | Data_Structure::Intent | intent, |
| const ApplicationStarterPtr & | starter, | ||
| const StopStrategyPtr & | stopStrategy, | ||
| const std::string & | commandLineParameters = "", | ||
| bool | printOnly = false ) |
Requests that the application be started, stopped or restarted, superseding any intent that has not been executed yet.
Returns immediately; the work happens on a worker thread.
| intent | what should happen to the application |
| starter | used to launch the application |
| stopStrategy | used to terminate the application |
Definition at line 58 of file ApplicationLifecycle.cpp.
Here is the call graph for this function:| void wait | ( | ) |
Blocks until nothing is requested or running any more.
Meant for callers that have to see the operation through before they can go away, such as the command line interface, which would otherwise exit while the worker is still launching. Returns immediately when the application is already idle.
Definition at line 103 of file ApplicationLifecycle.cpp.