ATLAS Offline Software
Loading...
Searching...
No Matches
InternalOnline.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef EVENTCONTAINERS_INTERNALONLINE_H
6#define EVENTCONTAINERS_INTERNALONLINE_H
7
10#include <atomic>
11#include <mutex>
13
14namespace EventContainers{
16/*
17The online implementation keeps a pointer to an external cache which owns the collections
18and can be filled concurrently. The container itself maintains a bit mask to identify which
19collections can be accessed from this container. It also maintains a wait list which records
20uncompleted objects that were added to the container. When a complete collection is
21requested the wait-list is processed, locking the thread until all elements are completed.
22The intention of this is to delay thread locking until the last possible moment and thus
23hopefully avoid it altogether.
24Random access is fast since it takes a direct index to the external cache element.
25Ordered iteration is also fast after the lazily initialised collection is constructed.
26*/
27class InternalOnline final : public I_InternalIDC {
28public:
30 virtual InternalConstItr cbegin() const override;
31 virtual InternalConstItr cend() const override;
32 virtual InternalConstItr indexFind( IdentifierHash hashId ) const override;
33 virtual const std::vector < hashPair >& getAllHashPtrPair() const override;
34 virtual ~InternalOnline()=default;
35 virtual void wait() const override;
37 virtual bool tryAddFromCache(IdentifierHash hashId) override;
38 virtual std::vector<IdentifierHash> getAllCurrentHashes() const override;
39 virtual size_t numberOfCollections() const override;
40 void resetMask();
41 virtual size_t fullSize() const noexcept override { return m_mask.size(); }
42 virtual StatusCode fetchOrCreate(IdentifierHash hashId) override;
43 virtual StatusCode fetchOrCreate(const std::vector<IdentifierHash> &hashIds) override;
44 virtual bool insert(IdentifierHash hashId, const void* ptr) override;
45 virtual const void* findIndexPtr(IdentifierHash hashId) const noexcept override;
46 virtual StatusCode addLock(IdentifierHash hashId, const void* ptr) override;
47 virtual void* removeCollection( IdentifierHash hashId ) override;
48 virtual void destructor(deleter_f*) noexcept override;
49 virtual void cleanUp(deleter_f*) noexcept override;
50private:
52 mutable std::vector< IdentifierHash > m_waitlist ATLAS_THREAD_SAFE;
53 mutable std::vector<I_InternalIDC::hashPair> m_map ATLAS_THREAD_SAFE;
54 mutable std::mutex m_waitMutex ATLAS_THREAD_SAFE;
56 mutable std::atomic<bool> m_waitNeeded ATLAS_THREAD_SAFE; //These mutables are carefully thought out, do not change
57};
58
59}
60#endif
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
Define macros for attributes used to control the static checker.
std::vector< hashPair >::const_iterator InternalConstItr
A class for a dynamic bit mask specialised for fast, ordered iteration using the forEachSetBit method...
virtual std::vector< IdentifierHash > getAllCurrentHashes() const override
virtual ~InternalOnline()=default
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.
void deleter_f(const void *p)
Definition deleter.h:13