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>
12
13namespace EventContainers{
15/*
16The online implementation keeps a pointer to an external cache which owns the collections
17and can be filled concurrently. The container itself maintains a bit mask to identify which
18collections can be accessed from this container. It also maintains a wait list which records
19uncompleted objects that were added to the container. When a complete collection is
20requested the wait-list is processed, locking the thread until all elements are completed.
21The intention of this is to delay thread locking until the last possible moment and thus
22hopefully avoid it altogether.
23Random access is fast since it takes a direct index to the external cache element.
24Ordered iteration is also fast after the lazily initialised collection is constructed.
25*/
26class InternalOnline final : public I_InternalIDC {
27public:
29 virtual InternalConstItr cbegin() const override;
30 virtual InternalConstItr cend() const override;
31 virtual InternalConstItr indexFind( IdentifierHash hashId ) const override;
32 virtual const std::vector < hashPair >& getAllHashPtrPair() const override;
33 virtual ~InternalOnline()=default;
34 virtual void wait() const override;
35 virtual bool tryAddFromCache(IdentifierHash hashId, EventContainers::IDC_WriteHandleBase &lock) override;
36 virtual bool tryAddFromCache(IdentifierHash hashId) override;
37 virtual std::vector<IdentifierHash> getAllCurrentHashes() const override;
38 virtual size_t numberOfCollections() const override;
39 void resetMask();
40 virtual size_t fullSize() const noexcept override { return m_mask.size(); }
41 virtual StatusCode fetchOrCreate(IdentifierHash hashId) override;
42 virtual StatusCode fetchOrCreate(const std::vector<IdentifierHash> &hashIds) override;
43 virtual bool insert(IdentifierHash hashId, const void* ptr) override;
44 virtual const void* findIndexPtr(IdentifierHash hashId) const noexcept override;
45 virtual StatusCode addLock(IdentifierHash hashId, const void* ptr) override;
46 virtual void* removeCollection( IdentifierHash hashId ) override;
47 virtual void destructor(deleter_f*) noexcept override;
48 virtual void cleanUp(deleter_f*) noexcept override;
49private:
51 mutable std::vector< IdentifierHash > m_waitlist ATLAS_THREAD_SAFE;
52 mutable std::vector<I_InternalIDC::hashPair> m_map ATLAS_THREAD_SAFE;
53 mutable std::mutex m_waitMutex ATLAS_THREAD_SAFE;
54 mutable std::vector<bool> m_mask ATLAS_THREAD_SAFE;
55 mutable std::atomic<bool> m_waitNeeded ATLAS_THREAD_SAFE; //These mutables are carefully thought out, do not change
56};
57
58}
59#endif
Define macros for attributes used to control the static checker.
std::vector< hashPair >::const_iterator InternalConstItr
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