Skip to content
Snippets Groups Projects
Commit 71efecaa authored by Adam Edward Barton's avatar Adam Edward Barton :speech_balloon: Committed by Atlas Nightlybuild
Browse files

Merge branch 'depset.AthenaKernel-20220805' into 'master'

AthenaKernel+StoreGate+AthenaServices: Use ConcurrentPtrSet for CondCont dependencies.

See merge request !55695

(cherry picked from commit 3e4a2415)

903748a0 AthenaKernel: Use ConcurrentPtrSet for CondCont dependencies.
e97ae022 StoreGate: Use ConcurrentPtrSet for CondCont dependencies.
9f093eb9 AthenaServices: Use ConcurrentPtrSet for CondCont dependencies.
7c706bcd fix sorting issue in WriteConfHandle_test
c6529eab diagnostic for failing tset
parent 09ff68b4
No related branches found
No related tags found
1 merge request!55768Sweeping !55695 from master to 22.0. AthenaKernel+StoreGate+AthenaServices: Use ConcurrentPtrSet for CondCont dependencies.
Pipeline #4346687 passed
......@@ -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;
......
......@@ -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());
}
......
......@@ -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);
}
......
......@@ -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() );
......
......@@ -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());
}
......
......@@ -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*> {});
}
......
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