ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
G4RunManagement
src
AtlasG4SyncEventUserInfo.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
G4RunManagement/AtlasG4SyncEventUserInfo.h
"
6
7
#include <memory>
8
#include <mutex>
9
10
//---------------------------------------------------------------------------
11
// AtlasG4SyncEventUserInfo
12
//---------------------------------------------------------------------------
13
14
AtlasG4SyncEventUserInfo::AtlasG4SyncEventUserInfo
(CLHEP::HepRandomEngine* rng_engine,
15
AtlasG4SyncEventUserInfo::EventFactoryFunction
&& event_factory,
16
const
EventContext& ctx)
17
:
AtlasG4EventUserInfo
(ctx)
18
,
m_rng_engine
(rng_engine)
19
,
m_event_factory
(
std
::move(event_factory))
20
,
m_sync_interface
(
std
::make_shared<
G4EventSynchronizationInterface
>())
21
{
22
}
23
24
//---------------------------------------------------------------------------
25
// G4EventSynchronizationInterface
26
//---------------------------------------------------------------------------
27
28
auto
G4EventSynchronizationInterface::Status
()
const
->
EventStatus
29
{
30
std::scoped_lock lk(
m_mutex
);
31
return
m_status
;
32
}
33
34
auto
G4EventSynchronizationInterface::Outcome
()
const
->
EventOutcome
35
{
36
std::scoped_lock lk(
m_mutex
);
37
return
m_outcome
;
38
}
39
40
void
G4EventSynchronizationInterface::Complete
(
EventOutcome
outcome)
noexcept
41
{
42
bool
completed =
false
;
43
{
44
std::scoped_lock lk(
m_mutex
);
45
if
(
m_status
==
EventStatus::Ready
) {
46
m_outcome
= outcome;
47
m_status
=
EventStatus::Done
;
48
completed =
true
;
49
}
50
}
51
if
(completed) {
52
m_cv
.notify_all();
53
}
54
}
55
56
void
G4EventSynchronizationInterface::WaitStatus
(
const
EventStatus
& status)
57
{
58
std::unique_lock lk(
m_mutex
);
59
m_cv
.wait(lk, [
this
,status]{
return
m_status
==status; });
60
}
AtlasG4SyncEventUserInfo.h
AtlasG4EventUserInfo::AtlasG4EventUserInfo
AtlasG4EventUserInfo(const EventContext &ctx)
Definition
AtlasG4EventUserInfo.h:28
AtlasG4SyncEventUserInfo::AtlasG4SyncEventUserInfo
AtlasG4SyncEventUserInfo(CLHEP::HepRandomEngine *, EventFactoryFunction &&, const EventContext &)
Definition
AtlasG4SyncEventUserInfo.cxx:14
AtlasG4SyncEventUserInfo::EventFactoryFunction
std::function< StatusCode(G4Event &)> EventFactoryFunction
Definition
AtlasG4SyncEventUserInfo.h:61
AtlasG4SyncEventUserInfo::m_event_factory
EventFactoryFunction m_event_factory
Definition
AtlasG4SyncEventUserInfo.h:94
AtlasG4SyncEventUserInfo::m_rng_engine
CLHEP::HepRandomEngine * m_rng_engine
Definition
AtlasG4SyncEventUserInfo.h:92
AtlasG4SyncEventUserInfo::m_sync_interface
SPSyncInterface m_sync_interface
Definition
AtlasG4SyncEventUserInfo.h:99
G4EventSynchronizationInterface
Definition
AtlasG4SyncEventUserInfo.h:28
G4EventSynchronizationInterface::EventStatus
EventStatus
Definition
AtlasG4SyncEventUserInfo.h:29
G4EventSynchronizationInterface::EventStatus::Ready
@ Ready
Definition
AtlasG4SyncEventUserInfo.h:30
G4EventSynchronizationInterface::EventStatus::Done
@ Done
Definition
AtlasG4SyncEventUserInfo.h:31
G4EventSynchronizationInterface::m_cv
std::condition_variable m_cv
Definition
AtlasG4SyncEventUserInfo.h:54
G4EventSynchronizationInterface::Status
EventStatus Status() const
Definition
AtlasG4SyncEventUserInfo.cxx:28
G4EventSynchronizationInterface::m_mutex
std::mutex m_mutex
Definition
AtlasG4SyncEventUserInfo.h:53
G4EventSynchronizationInterface::m_outcome
EventOutcome m_outcome
Definition
AtlasG4SyncEventUserInfo.h:51
G4EventSynchronizationInterface::WaitStatus
void WaitStatus(const EventStatus &)
Definition
AtlasG4SyncEventUserInfo.cxx:56
G4EventSynchronizationInterface::Outcome
EventOutcome Outcome() const
Definition
AtlasG4SyncEventUserInfo.cxx:34
G4EventSynchronizationInterface::EventOutcome
EventOutcome
Definition
AtlasG4SyncEventUserInfo.h:35
G4EventSynchronizationInterface::Complete
void Complete(EventOutcome outcome) noexcept
Record the first completion outcome and wake Athena.
Definition
AtlasG4SyncEventUserInfo.cxx:40
G4EventSynchronizationInterface::m_status
EventStatus m_status
Definition
AtlasG4SyncEventUserInfo.h:52
const
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0