diff --git a/Control/AthenaKernel/AthenaKernel/CondCont.h b/Control/AthenaKernel/AthenaKernel/CondCont.h index ee0e016a0c1cbe4d1dc988e8d357bd977c4e420c..b66d4b8befa7806c6cb92bcf6c79ca4fc6517fd8 100644 --- a/Control/AthenaKernel/AthenaKernel/CondCont.h +++ b/Control/AthenaKernel/AthenaKernel/CondCont.h @@ -73,6 +73,8 @@ #include "AthenaKernel/IConditionsCleanerSvc.h" #include "AthenaKernel/CondObjDeleter.h" #include "CxxUtils/ConcurrentRangeMap.h" +#include "CxxUtils/ConcurrentPtrSet.h" +#include "CxxUtils/SimpleUpdater.h" #include "CxxUtils/checker_macros.h" #include "GaudiKernel/EventIDBase.h" @@ -482,10 +484,10 @@ public: /** - * @brief Declare other conditions containers that depend on this one. - * @param deps Conditions containers that depend on this one. + * @brief Declare another conditions container that depends on this one. + * @param dep Conditions container that depends on this one. */ - void addDeps (const std::vector<CondContBase*>& deps); + void addDep (CondContBase* dep); /** @@ -669,12 +671,9 @@ private: ServiceHandle<Athena::IConditionsCleanerSvc> m_cleanerSvc; /// Other conditions dependencies that depend on this one, as inferred - /// by addDependency calls. There should only be a few of them, - /// so just use a simple vector. - std::vector<CondContBase*> m_deps; - - /// Serialize access to m_deps. - mutable std::mutex m_depMutex; + /// by addDependency calls. There should only be a few of them. + using DepSet = CxxUtils::ConcurrentPtrSet<CondContBase, CxxUtils::SimpleUpdater>; + DepSet m_deps; /// Name of the global conditions cleaner service. static std::string s_cleanerSvcName ATLAS_THREAD_SAFE; diff --git a/Control/AthenaKernel/src/CondCont.cxx b/Control/AthenaKernel/src/CondCont.cxx index 345a67f87223f1eb2d946fc7c68657dfcf949e44..336461f5ccd86b4fcfa17d189faf1a10ba779e6d 100644 --- a/Control/AthenaKernel/src/CondCont.cxx +++ b/Control/AthenaKernel/src/CondCont.cxx @@ -407,7 +407,8 @@ CondContBase::CondContBase (Athena::IRCUSvc& rcusvc, m_id (id), m_proxy (proxy), m_condSet (Updater_t (rcusvc), payloadDeleter, capacity), - m_cleanerSvc (s_cleanerSvcName, "CondContBase") + m_cleanerSvc (s_cleanerSvcName, "CondContBase"), + m_deps (DepSet::Updater_t(), 16) { if (!m_cleanerSvc.retrieve().isSuccess()) { std::abort(); @@ -678,19 +679,12 @@ StatusCode CondContBase::inserted (const EventContext& ctx) /** - * @brief Declare other conditions containers that depend on this one. - * @param deps Conditions containers that depend on this one. + * @brief Declare another conditions container that depends on this one. + * @param dep Conditions container that depends on this one. */ -void CondContBase::addDeps (const std::vector<CondContBase*>& deps) +void CondContBase::addDep (CondContBase* dep) { - if (deps.empty()) return; - std::scoped_lock lock (m_depMutex); - m_deps.insert (m_deps.end(), deps.begin(), deps.end()); - - // Remove duplicates. - std::sort (m_deps.begin(), m_deps.end()); - auto it = std::unique (m_deps.begin(), m_deps.end()); - m_deps.resize (it - m_deps.begin()); + m_deps.insert (dep); } @@ -699,8 +693,7 @@ void CondContBase::addDeps (const std::vector<CondContBase*>& deps) */ std::vector<CondContBase*> CondContBase::getDeps() { - std::scoped_lock lock (m_depMutex); - return m_deps; + return std::vector<CondContBase*> (m_deps.begin(), m_deps.end()); } diff --git a/Control/AthenaKernel/test/CondCont_test.cxx b/Control/AthenaKernel/test/CondCont_test.cxx index c4b09283071b2ea8f7b30d12026884dd86118493..15b5fe7786dfb63b55e1ad1a404ba98195d13862 100644 --- a/Control/AthenaKernel/test/CondCont_test.cxx +++ b/Control/AthenaKernel/test/CondCont_test.cxx @@ -787,9 +787,11 @@ void test5 (TestRCUSvc& rcusvc) exp2 << "{[2,t:120,l:10] - [2,t:130,l:20]} " << bptrs[5] << "\n"; exp2 << "{[2,t:130,l:10] - [2,t:135,l:20]} " << bptrs[6] << "\n"; exp2 << "{[20,t:120,l:10] - [20,t:130,l:40]} " << bptrs[8] << "\n"; - // xxx - //std::cout << "ss2: " << ss2.str() << "\nexp2: " << exp2.str() << "\n"; - assert (ss2.str() == exp2.str()); + if (ss2.str() != exp2.str()) { + std::cout << "ss2: " << ss2.str() << "\nexp2: " << exp2.str() << "\n"; + std::cout.flush(); + std::abort(); + } } @@ -870,10 +872,11 @@ void test7 (TestRCUSvc& rcusvc) assert (cc1.getDeps().empty()); std::vector<CondContBase*> v { &cc2, &cc3 }; - cc1.addDeps (v); + cc1.addDep (&cc2); + cc1.addDep (&cc3); std::sort (v.begin(), v.end()); assert (cc1.getDeps() == v); - cc1.addDeps (std::vector<CondContBase*> { &cc3 }); + cc1.addDep (&cc3); assert (cc1.getDeps() == v); } diff --git a/Control/AthenaServices/test/DelayedConditionsCleanerSvc_test.cxx b/Control/AthenaServices/test/DelayedConditionsCleanerSvc_test.cxx index dd526579b4e6d6d41a9f6363105416806cd17ea2..89c839a4709413ee858f69578b3eda048e72c1d9 100644 --- a/Control/AthenaServices/test/DelayedConditionsCleanerSvc_test.cxx +++ b/Control/AthenaServices/test/DelayedConditionsCleanerSvc_test.cxx @@ -276,7 +276,7 @@ void test2 (Athena::IConditionsCleanerSvc& svc) CondContTest cc1 (rcu, id, 10, CondContBase::KeyType::TIMESTAMP); CondContTest cc2 (rcu, id, 10, CondContBase::KeyType::TIMESTAMP); - cc1.addDeps (std::vector<CondContBase*> { &cc2 }); + cc1.addDep (&cc2); assert( svc.condObjAdded (makeCtx(1000), cc1).isSuccess() ); assert( svc.condObjAdded (makeCtx(2000), cc2).isSuccess() ); diff --git a/Control/StoreGate/StoreGate/WriteCondHandle.h b/Control/StoreGate/StoreGate/WriteCondHandle.h index 8f7e0a7bf4d62c2be7aab732807426dfd07a9bb0..ce790f535b24de975de7778fc69a2184f77e3c93 100644 --- a/Control/StoreGate/StoreGate/WriteCondHandle.h +++ b/Control/StoreGate/StoreGate/WriteCondHandle.h @@ -300,7 +300,7 @@ namespace SG { void WriteCondHandle<T>::addDependency(SG::ReadCondHandle<R>& rch) { CondContBase* dep_cc = rch.getCC(); - dep_cc->addDeps (std::vector<CondContBase*> { m_cc }); + dep_cc->addDep (m_cc); return addDependency(rch.getRange()); } diff --git a/Control/StoreGate/test/WriteCondHandle_test.cxx b/Control/StoreGate/test/WriteCondHandle_test.cxx index 69edb40828f0c437a1c95fd482ce71f643a96bfd..850cb20c27862aff2557e0b20a89998297d5a31b 100644 --- a/Control/StoreGate/test/WriteCondHandle_test.cxx +++ b/Control/StoreGate/test/WriteCondHandle_test.cxx @@ -503,7 +503,9 @@ void test3( StoreGateSvc* cs ) std::vector<CondContBase*> v { cc3, cc4 }; std::sort (v.begin(), v.end()); assert (cc1->getDeps() == std::vector<CondContBase*> {cc3}); - assert (cc2->getDeps() == v); + std::vector<CondContBase*> v2 = cc2->getDeps(); + std::sort (v2.begin(), v2.end()); + assert (v2 == v); assert (cc3->getDeps() == std::vector<CondContBase*> {}); assert (cc4->getDeps() == std::vector<CondContBase*> {}); @@ -520,7 +522,9 @@ void test3( StoreGateSvc* cs ) } assert (cc1->getDeps() == std::vector<CondContBase*> {cc3}); - assert (cc2->getDeps() == v); + v2 = cc2->getDeps(); + std::sort (v2.begin(), v2.end()); + assert (v2 == v); assert (cc3->getDeps() == std::vector<CondContBase*> {}); assert (cc4->getDeps() == std::vector<CondContBase*> {}); }