Skip to content
Snippets Groups Projects
Commit 38a0eebc authored by scott snyder's avatar scott snyder Committed by scott snyder
Browse files

CaloG4Sim: Enable thread-safety checking.

Enable thread-safety checking.
Clean up resulting warnings.
parent 1cadeef5
No related branches found
No related tags found
No related merge requests found
Calorimeter/CaloG4Sim
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CaloG4_EscapedEnergyRegistry_H
#define CaloG4_EscapedEnergyRegistry_H
#include "CaloG4Sim/VEscapedEnergyProcessing.h"
#include "CxxUtils/checker_macros.h"
#include "globals.hh"
#include <map>
......@@ -75,7 +76,7 @@ namespace CaloG4
// Thread-to-EscapeEnergyRegistry concurrent map type
using EERThreadMap_t = tbb::concurrent_unordered_map< std::thread::id, EscapedEnergyRegistry*, std::hash<std::thread::id> >;
// Concurrent map of EERs, one for each thread
static EERThreadMap_t m_EERThreadMap;
static EERThreadMap_t m_EERThreadMap ATLAS_THREAD_SAFE;
// @brief Search inside m_EERThreadMap the element with the current threadID
// and return it or return a null pointer if the element is not found
static EscapedEnergyRegistry* getEER();
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
// CalibrationDefaultProcessing
......@@ -20,6 +20,7 @@
#include "CaloG4Sim/CalibrationDefaultProcessing.h"
#include "CaloG4Sim/SimulationEnergies.h"
#include "CxxUtils/checker_macros.h"
// For the event-level flag
#include "MCTruth/AtlasG4EventUserInfo.h"
......@@ -32,6 +33,7 @@
#include "GaudiKernel/Bootstrap.h"
#include "GaudiKernel/ISvcLocator.h"
#include <atomic>
namespace G4UA
{
......@@ -79,7 +81,9 @@ namespace G4UA
// this step. Note that we have to "cast away" const-ness for
// the G4Step*, due to how G4VSensitiveDetector::Hit() is
// defined.
m_defaultSD->Hit( const_cast<G4Step*>(a_step) );
// Should be ok, since Geant doesn't do intra-event parallelism.
G4Step* step_nc ATLAS_THREAD_SAFE = const_cast<G4Step*> (a_step);
m_defaultSD->Hit( step_nc );
// Update the step info
atlasG4EvtUserInfo->SetLastProcessedBarcode( track->GetTrackID() );
......@@ -88,10 +92,8 @@ namespace G4UA
}
else {
// FIXME - thread unsafe static!!!
static G4bool warningPrinted = false;
if ( ! warningPrinted ) {
warningPrinted = true;
static std::atomic_flag warningPrinted ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT;
if ( ! warningPrinted.test_and_set() ) {
G4cout << "CaloG4::CalibrationDefaultProcessing::SteppingAction - "
<< G4endl
<< " A default calibration sensitive detector was not defined."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment