ATLAS Offline Software
Loading...
Searching...
No Matches
InternalOfflineMap.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_InternalOfflineMap_H
6#define EVENTCONTAINERS_InternalOfflineMap_H
9#include <atomic>
10#include <mutex>
11#include <unordered_map>
12
13namespace EventContainers{
14/*
15This class implements the IdentifiableContainer code for the offline case.
16This class balances speed against memory usage by using an unordered_map
17
18Moderately fast random access, fast iteration, moderate memory usage.
19*/
20class InternalOfflineMap final : public I_InternalIDC {
21public:
22 InternalOfflineMap(size_t max);
23 virtual ~InternalOfflineMap()=default;
24 virtual InternalConstItr cbegin() const override;
25 virtual InternalConstItr cend() const override;
26 virtual InternalConstItr indexFind( IdentifierHash hashId ) const override;
27 virtual const std::vector < hashPair >& getAllHashPtrPair() const override;
28 virtual bool tryAddFromCache(IdentifierHash hashId, EventContainers::IDC_WriteHandleBase &lock) override;
29 virtual bool tryAddFromCache(IdentifierHash hashId) override;
30 virtual void wait() const override;
31 virtual std::vector<IdentifierHash> getAllCurrentHashes() const override;
32 virtual size_t numberOfCollections() const override;
33 virtual void cleanUp(deleter_f* deleter) noexcept override;
34 virtual size_t fullSize() const noexcept override {return m_maxsize;}
35 virtual StatusCode fetchOrCreate(IdentifierHash hashId) override;
36 virtual StatusCode fetchOrCreate(const std::vector<IdentifierHash> &hashIds) override;
37 virtual bool insert(IdentifierHash hashId, const void* ptr) override;
38 virtual const void* findIndexPtr(IdentifierHash hashId) const noexcept override;
39 virtual StatusCode addLock(IdentifierHash hashId, const void* ptr) override;
40 virtual void* removeCollection( IdentifierHash hashId ) override;
41 virtual void destructor(deleter_f*) noexcept override;
42private:
43 mutable std::vector<I_InternalIDC::hashPair> m_map ATLAS_THREAD_SAFE;
44 std::unordered_map<IdentifierHash::value_type, const void*> m_fullMap;
45 mutable std::mutex m_waitMutex ATLAS_THREAD_SAFE;
46 mutable std::atomic<bool> m_needsupdate ATLAS_THREAD_SAFE; //These mutables are carefully thought out, do not change
47 const size_t m_maxsize;
48};
49
50}
51#endif
#define max(a, b)
Definition cfImp.cxx:41
Define macros for attributes used to control the static checker.
std::vector< hashPair >::const_iterator InternalConstItr
void deleter_f(const void *p)
virtual InternalConstItr indexFind(IdentifierHash hashId) const override
std::vector< I_InternalIDC::hashPair > m_map ATLAS_THREAD_SAFE
virtual InternalConstItr cend() const override
virtual size_t numberOfCollections() const override
virtual void wait() const override
virtual void cleanUp(deleter_f *deleter) noexcept override
virtual void * removeCollection(IdentifierHash hashId) override
virtual size_t fullSize() const noexcept override
virtual bool tryAddFromCache(IdentifierHash hashId, EventContainers::IDC_WriteHandleBase &lock) override
std::unordered_map< IdentifierHash::value_type, const void * > m_fullMap
virtual std::vector< IdentifierHash > getAllCurrentHashes() const override
virtual const void * findIndexPtr(IdentifierHash hashId) const noexcept override
virtual void destructor(deleter_f *) noexcept override
virtual const std::vector< hashPair > & getAllHashPtrPair() const override
virtual InternalConstItr cbegin() const override
virtual bool insert(IdentifierHash hashId, const void *ptr) override
virtual StatusCode fetchOrCreate(IdentifierHash hashId) override
virtual StatusCode addLock(IdentifierHash hashId, const void *ptr) override
This is a "hash" representation of an Identifier.
void deleter_f(const void *p)
Definition deleter.h:13