From b40b4b50ffef2afe98862c791c5ce9a0ac25221d Mon Sep 17 00:00:00 2001 From: scott snyder <sss@karma> Date: Tue, 18 Aug 2020 23:31:00 -0400 Subject: [PATCH] NavFourMom: Thread-safety fix. Don't declare copy conversion classes as not thread safe; instead, declare the const_cast inside as thread-safe. It would be better to change the interfaces so that this isn't required, but probably not worth the effort just for these run 1 classes. --- Event/NavFourMom/NavFourMom/INav4MomLinkContainer.h | 10 +++++++--- Event/NavFourMom/NavFourMom/IParticleLinkContainer.h | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Event/NavFourMom/NavFourMom/INav4MomLinkContainer.h b/Event/NavFourMom/NavFourMom/INav4MomLinkContainer.h index 4cac434d8ab..eb69363dd69 100644 --- a/Event/NavFourMom/NavFourMom/INav4MomLinkContainer.h +++ b/Event/NavFourMom/NavFourMom/INav4MomLinkContainer.h @@ -1,7 +1,7 @@ ///////////////////////// -*- C++ -*- ///////////////////////////// /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /** INav4MomLinkContainer.h @@ -33,7 +33,7 @@ CLASS_DEF( INav4MomLinkContainer , 1194917823 , 1 ) // This defines how to convert an INav4MomLinkContainer to an INavigable4MomentumCollection -class ATLAS_NOT_THREAD_SAFE INav4MomLinkContainerToINavigable4MomentumCollectionConverter +class INav4MomLinkContainerToINavigable4MomentumCollectionConverter : public SG::CopyConversion<INav4MomLinkContainer, INavigable4MomentumCollection> { @@ -47,7 +47,11 @@ public: dst.reserve (sz); for (size_t i = 0; i < sz; i++) { const INavigable4Momentum* p = *(src[i]).cptr(); - dst.push_back (const_cast<INavigable4Momentum*> (p)); + // FIXME: Ok, since the target ends up recorded in the event + // store as const. But should change the interfaces so that + // we get a ConstDataVector to fill. + INavigable4Momentum* p_nc ATLAS_THREAD_SAFE = const_cast<INavigable4Momentum*> (p); + dst.push_back (p_nc); } } } diff --git a/Event/NavFourMom/NavFourMom/IParticleLinkContainer.h b/Event/NavFourMom/NavFourMom/IParticleLinkContainer.h index 812b223afb4..57e3e8dff1e 100644 --- a/Event/NavFourMom/NavFourMom/IParticleLinkContainer.h +++ b/Event/NavFourMom/NavFourMom/IParticleLinkContainer.h @@ -34,7 +34,7 @@ CLASS_DEF( IParticleLinkContainer , 1340008338 , 1 ) // This defines how to convert an INav4MomLinkContainer to an INavigable4MomentumCollection -class ATLAS_NOT_THREAD_SAFE IParticleLinkContainerToIParticleContainerConverter +class IParticleLinkContainerToIParticleContainerConverter : public SG::CopyConversion<IParticleLinkContainer, IParticleContainer> { @@ -48,7 +48,11 @@ public: dst.reserve (sz); for (size_t i = 0; i < sz; i++) { const IParticle* p = *(src[i]).cptr(); - dst.push_back (const_cast<IParticle*> (p)); + // FIXME: Ok, since the target ends up recorded in the event + // store as const. But should change the interfaces so that + // we get a ConstDataVector to fill. + IParticle* p_nc ATLAS_THREAD_SAFE = const_cast<IParticle*> (p); + dst.push_back (p_nc); } } } -- GitLab