17 m_mask(cache->
fullSize()), m_waitNeeded(false) {}
20 if(m_waitNeeded.load(std::memory_order_acquire))
wait();
27 if(m_waitNeeded.load(std::memory_order_acquire))
wait();
33 if(m_waitNeeded.load(std::memory_order_acquire))
wait();
34 return m_map.cbegin();
38 if(m_waitNeeded.load(std::memory_order_acquire))
wait();
40 if(itr!= m_map.end() && itr->first==hashId)
return itr;
46 std::scoped_lock
lock (m_waitMutex);
47 if(m_waitNeeded.load(std::memory_order_acquire) ==
false)
return;
50 while(!m_waitlist.empty()) {
53 const void* ptr = cacheLink->waitFor(hash);
54 if(ptr == ABORTstate) {
57 m_waitlist.pop_back();
60 m_mask.forEachSetBit([
this](
size_t index) {
62 m_map.emplace_back(
index, ptr);
66 m_waitNeeded.store(
false, std::memory_order_seq_cst);
72 if(!m_waitlist.empty()) m_waitNeeded.store(
true, std::memory_order_relaxed);
76 m_waitNeeded.store(
true, std::memory_order_relaxed);
90 m_waitNeeded.store(
true, std::memory_order_relaxed);
95 if(m_waitNeeded.load(std::memory_order_acquire))
wait();
96 std::vector<IdentifierHash> ids;
97 ids.reserve(m_map.size());
98 for(
auto &
x : m_map) {
99 ids.emplace_back(
x.first);
105 if(m_waitNeeded.load(std::memory_order_acquire))
wait();
110 if(m_waitNeeded.load(std::memory_order_relaxed))
wait();
113 m_waitNeeded.store(
true, std::memory_order_relaxed);
119 if(ptr) { m_mask.set(hashId); m_waitNeeded.store(
true, std::memory_order_relaxed); }
120 return StatusCode::SUCCESS;
124 throw std::runtime_error(
"Not implemented");
132 std::pair<bool, const void*> cacheinserted =
m_cacheLink->add(hashId, ptr);
134 m_waitNeeded.store(
true, std::memory_order_relaxed);
135 return ptr == cacheinserted.second;
139 if(hashId < m_mask.size() and m_mask.test(hashId)) {
141 return cacheLink->findWait(hashId);
147 std::pair<bool, const void*> added =
m_cacheLink->addLock(hashId, ptr);
149 throw std::runtime_error(
"IDC WARNING Deletion shouldn't occur in addLock paradigm");
152 m_waitNeeded.store(
true, std::memory_order_relaxed);
153 return StatusCode::SUCCESS;
157 throw std::runtime_error(
"Do not remove things from an online IDC");
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
I_InternalIDC::InternalConstItr InternalConstItr
Define macros for attributes used to control the static checker.
std::vector< hashPair >::const_iterator InternalConstItr
EventContainers::hashPair< void > hashPair
void deleter_f(const void *p)
static constexpr uintptr_t ABORTEDflag
virtual std::vector< IdentifierHash > getAllCurrentHashes() const override
virtual InternalConstItr indexFind(IdentifierHash hashId) const override
std::vector< IdentifierHash > m_waitlist ATLAS_THREAD_SAFE
virtual StatusCode addLock(IdentifierHash hashId, const void *ptr) override
virtual bool insert(IdentifierHash hashId, const void *ptr) override
virtual const void * findIndexPtr(IdentifierHash hashId) const noexcept override
virtual void wait() const override
virtual void cleanUp(deleter_f *) noexcept override
virtual bool tryAddFromCache(IdentifierHash hashId, EventContainers::IDC_WriteHandleBase &lock) override
virtual size_t fullSize() const noexcept override
virtual StatusCode fetchOrCreate(IdentifierHash hashId) override
virtual void destructor(deleter_f *) noexcept override
virtual void * removeCollection(IdentifierHash hashId) override
virtual const std::vector< hashPair > & getAllHashPtrPair() const override
virtual InternalConstItr cbegin() const override
InternalOnline(EventContainers::IdentifiableCacheBase *cache)
virtual InternalConstItr cend() const override
virtual size_t numberOfCollections() const override
EventContainers::IdentifiableCacheBase * m_cacheLink
This is a "hash" representation of an Identifier.
constexpr value_type value() const