ATLAS Offline Software
Loading...
Searching...
No Matches
G4RunToolStateSynchronization.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <utility>
8
10{
11 {
12 std::scoped_lock lk(m_mutex);
15 }
16 }
17 m_cv.notify_all();
18}
19
21{
22 {
23 std::scoped_lock lk(m_mutex);
26 }
27 }
28 m_cv.notify_all();
29}
30
31void G4RunToolStateSynchronization::Fail(std::string message)
32{
33 {
34 std::scoped_lock lk(m_mutex);
35 // Preserve the first terminal outcome and its diagnostic message.
37 m_failureMessage = std::move(message);
39 }
40 }
41 m_cv.notify_all();
42}
43
45{
46 {
47 std::scoped_lock lk(m_mutex);
49 if (m_failureMessage.empty()) {
51 "Geant4 main thread exited without completing its lifecycle";
52 }
54 }
57 }
58 }
59 m_cv.notify_all();
60}
61
63 std::string& failureMessage)
64{
65 std::unique_lock lk(m_mutex);
66 m_cv.wait(lk, [this]{ return m_status != Status::Starting; });
68 return true;
69 }
70
71 failureMessage = m_failureMessage;
72 if (failureMessage.empty()) {
73 failureMessage = "Geant4 stopped before beginning a run";
74 }
75 return false;
76}
77
void NotifyBeginRun()
Transition Starting to Running. Ignored in every other state.
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.
void NotifyThreadExit()
Record normal exit after finalization, or failure after an unexpected exit.
@ FinalizeRequested
Athena requested termination of the Geant4 run loop.
@ Running
BeginOfRun was observed; Athena may submit events.
@ Stopped
The Geant4 main thread exited normally; terminal state.
@ Starting
Waiting for the first Geant4 BeginOfRun notification.
@ Failed
The Geant4 main thread failed; terminal state.
void Fail(std::string message)
Transition any non-terminal state to Failed and wake startup waiters.
void RequestFinalize()
Transition Starting or Running to FinalizeRequested.