diff --git a/Simulation/G4Extensions/G4ExternalDecay/CMakeLists.txt b/Simulation/G4Extensions/G4ExternalDecay/CMakeLists.txt index 181c1a740d5cd5fa2fd3cb55806e2f2766c5d47a..619384a27e8db65a1a0d2f99e3eccd954cf1bf7a 100644 --- a/Simulation/G4Extensions/G4ExternalDecay/CMakeLists.txt +++ b/Simulation/G4Extensions/G4ExternalDecay/CMakeLists.txt @@ -1,6 +1,4 @@ -################################################################################ -# Package: G4ExternalDecay -################################################################################ +# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration # Declare the package name: atlas_subdir( G4ExternalDecay ) @@ -37,5 +35,5 @@ atlas_add_library( G4ExternalDecay INCLUDE_DIRS ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${LHAPDF_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${PYTHIA8_INCLUDE_DIRS} ${extra_includes} PRIVATE_INCLUDE_DIRS DEFINITIONS ${CLHEP_DEFINITIONS} - LINK_LIBRARIES ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} ${PYTHIA8_LIBRARIES} ${LHAPDF_LIBRARIES} ${GEANT4_LIBRARIES} Pythia8_iLib ${extra_libs} + LINK_LIBRARIES ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} ${PYTHIA8_LIBRARIES} ${LHAPDF_LIBRARIES} ${GEANT4_LIBRARIES} CxxUtils Pythia8_iLib ${extra_libs} PRIVATE_LINK_LIBRARIES AtlasHepMCLib ) diff --git a/Simulation/G4Extensions/G4ExternalDecay/G4ExternalDecay/ATLAS_CHECK_THREAD_SAFETY b/Simulation/G4Extensions/G4ExternalDecay/G4ExternalDecay/ATLAS_CHECK_THREAD_SAFETY new file mode 100644 index 0000000000000000000000000000000000000000..9271bccd5d6b2cff4e135fb7533d9f1d5d6c0a2e --- /dev/null +++ b/Simulation/G4Extensions/G4ExternalDecay/G4ExternalDecay/ATLAS_CHECK_THREAD_SAFETY @@ -0,0 +1 @@ +Simulation/G4Extensions/G4ExternalDecay diff --git a/Simulation/G4Extensions/G4ExternalDecay/G4ExternalDecay/Pythia8ForDecays.h b/Simulation/G4Extensions/G4ExternalDecay/G4ExternalDecay/Pythia8ForDecays.h index a782ed4ef76e98df701dc9bfe01bc1098e787ab4..d9e5c6148e090ae8bdb9ecfae093125dafec8f15 100644 --- a/Simulation/G4Extensions/G4ExternalDecay/G4ExternalDecay/Pythia8ForDecays.h +++ b/Simulation/G4Extensions/G4ExternalDecay/G4ExternalDecay/Pythia8ForDecays.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ // Abused from Geant4 version of Pythai6.hh from extended examples @@ -15,9 +15,10 @@ #include // For all the various Pythia8 classes used here #include "Pythia8_i/Pythia8_i.h" -// For unique_ptr and once flag +// For unique_ptr #include -#include +// For ATLAS THREAD macros +#include "CxxUtils/checker_macros.h" class G4DynamicParticle; class G4ParticleDefinition; @@ -28,7 +29,7 @@ class Pythia8ForDecays virtual ~Pythia8ForDecays() = default; - static Pythia8ForDecays *Instance(); + static Pythia8ForDecays *Instance ATLAS_NOT_THREAD_SAFE (); /// Function that decays the RHadron; returns products in G4 format void Py1ent(const G4Track&, std::vector &); @@ -49,10 +50,6 @@ class Pythia8ForDecays std::pair fromIdWithSquark( int idRHad) const; bool isGluinoRHadron(int pdgId) const; - /// My own class; singleton pattern; thread safe for future-proofing - static std::unique_ptr s_instance; - static std::once_flag m_onceFlag; - /// The instance of Pythia8 that will do the work std::unique_ptr m_pythia; }; diff --git a/Simulation/G4Extensions/G4ExternalDecay/src/Pythia8ForDecays.cxx b/Simulation/G4Extensions/G4ExternalDecay/src/Pythia8ForDecays.cxx index c5173dcb754dd5d7b1fa06e61256355d82569f5c..fa7eba76cb61de3044c2ffe630545ab6fdd15d85 100644 --- a/Simulation/G4Extensions/G4ExternalDecay/src/Pythia8ForDecays.cxx +++ b/Simulation/G4Extensions/G4ExternalDecay/src/Pythia8ForDecays.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration */ // Abused from Pythia6.cc in Geant4 extended examples @@ -30,15 +30,10 @@ #include #include -std::unique_ptr Pythia8ForDecays::s_instance(nullptr); -std::once_flag Pythia8ForDecays::m_onceFlag; -Pythia8ForDecays* Pythia8ForDecays::Instance() { - std::call_once(m_onceFlag, - [] { - s_instance.reset(new Pythia8ForDecays); - }); - return s_instance.get(); +Pythia8ForDecays* Pythia8ForDecays::Instance ATLAS_NOT_THREAD_SAFE () { + static Pythia8ForDecays instance; + return &instance; } Pythia8ForDecays::Pythia8ForDecays()