![]() |
ATLAS Offline Software
|
Thread-safe lifecycle state shared by the Athena and Geant4 main threads. More...
#include <G4RunToolStateSynchronization.h>
Public Types | |
| enum class | Status { Starting , Running , FinalizeRequested , Failed , Stopped } |
Public Member Functions | |
| void | NotifyBeginRun () |
| Transition Starting to Running. Ignored in every other state. | |
| void | RequestFinalize () |
| Transition Starting or Running to FinalizeRequested. | |
| void | Fail (std::string message) |
| Transition any non-terminal state to Failed and wake startup waiters. | |
| void | NotifyThreadExit () |
| Record normal exit after finalization, or failure after an unexpected exit. | |
| bool | WaitBeginRun (std::string &failureMessage) |
| Wait until startup succeeds or the lifecycle reaches a terminal condition. | |
| bool | StopRequested () const |
| Return whether the Geant4 run loop must stop. | |
Private Attributes | |
| Status | m_status {Status::Starting} |
| std::string | m_failureMessage |
| std::mutex | m_mutex |
| std::condition_variable | m_cv |
Thread-safe lifecycle state shared by the Athena and Geant4 main threads.
The normal lifecycle is:
Starting –NotifyBeginRun()--> Running Starting/Running –RequestFinalize()--> FinalizeRequested FinalizeRequested –NotifyThreadExit()--> Stopped
A failure before normal thread exit instead transitions Starting, Running or FinalizeRequested to Failed. An unexpected thread exit while Starting or Running is also treated as a failure. Failed and Stopped are terminal states; late BeginOfRun, finalize and failure notifications cannot leave them.
Definition at line 24 of file G4RunToolStateSynchronization.h.
|
strong |
| Enumerator | |
|---|---|
| Starting | Waiting for the first Geant4 BeginOfRun notification. |
| Running | BeginOfRun was observed; Athena may submit events. |
| FinalizeRequested | Athena requested termination of the Geant4 run loop. |
| Failed | The Geant4 main thread failed; terminal state. |
| Stopped | The Geant4 main thread exited normally; terminal state. |
Definition at line 27 of file G4RunToolStateSynchronization.h.
| void G4RunToolStateSynchronization::Fail | ( | std::string | message | ) |
Transition any non-terminal state to Failed and wake startup waiters.
Definition at line 31 of file G4RunToolStateSynchronization.cxx.
| void G4RunToolStateSynchronization::NotifyBeginRun | ( | ) |
Transition Starting to Running. Ignored in every other state.
Definition at line 9 of file G4RunToolStateSynchronization.cxx.
| void G4RunToolStateSynchronization::NotifyThreadExit | ( | ) |
Record normal exit after finalization, or failure after an unexpected exit.
Definition at line 44 of file G4RunToolStateSynchronization.cxx.
| void G4RunToolStateSynchronization::RequestFinalize | ( | ) |
Transition Starting or Running to FinalizeRequested.
Definition at line 20 of file G4RunToolStateSynchronization.cxx.
| bool G4RunToolStateSynchronization::StopRequested | ( | ) | const |
Return whether the Geant4 run loop must stop.
Definition at line 78 of file G4RunToolStateSynchronization.cxx.
| bool G4RunToolStateSynchronization::WaitBeginRun | ( | std::string & | failureMessage | ) |
Wait until startup succeeds or the lifecycle reaches a terminal condition.
Definition at line 62 of file G4RunToolStateSynchronization.cxx.
|
private |
Definition at line 52 of file G4RunToolStateSynchronization.h.
|
private |
Definition at line 50 of file G4RunToolStateSynchronization.h.
|
mutableprivate |
Definition at line 51 of file G4RunToolStateSynchronization.h.
|
private |
Definition at line 49 of file G4RunToolStateSynchronization.h.