ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
7#include <memory>
8#include <mutex>
9
10//---------------------------------------------------------------------------
11// AtlasG4SyncEventUserInfo
12//---------------------------------------------------------------------------
13
14AtlasG4SyncEventUserInfo::AtlasG4SyncEventUserInfo(CLHEP::HepRandomEngine* rng_engine,
16 const EventContext& ctx)
18 , m_rng_engine(rng_engine)
19 , m_event_factory(std::move(event_factory))
21{
22}
23
24//---------------------------------------------------------------------------
25// G4EventSynchronizationInterface
26//---------------------------------------------------------------------------
27
29{
30 std::scoped_lock lk(m_mutex);
31 return m_status;
32}
33
35{
36 std::scoped_lock lk(m_mutex);
37 return m_outcome;
38}
39
41{
42 bool completed = false;
43 {
44 std::scoped_lock lk(m_mutex);
46 m_outcome = outcome;
48 completed = true;
49 }
50 }
51 if (completed) {
52 m_cv.notify_all();
53 }
54}
55
57{
58 std::unique_lock lk(m_mutex);
59 m_cv.wait(lk, [this,status]{ return m_status==status; });
60}
AtlasG4EventUserInfo(const EventContext &ctx)
AtlasG4SyncEventUserInfo(CLHEP::HepRandomEngine *, EventFactoryFunction &&, const EventContext &)
std::function< StatusCode(G4Event &)> EventFactoryFunction
EventFactoryFunction m_event_factory
CLHEP::HepRandomEngine * m_rng_engine
void Complete(EventOutcome outcome) noexcept
Record the first completion outcome and wake Athena.
STL namespace.