ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
EventContainers
EventContainers
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
8
#include "
EventContainers/I_InternalIDC.h
"
9
#include "
CxxUtils/checker_macros.h
"
10
#include <atomic>
11
#include <mutex>
12
#include "
EventContainers/IdentifierMask.h
"
13
14
namespace
EventContainers
{
15
class
IdentifiableCacheBase
;
16
/*
17
The online implementation keeps a pointer to an external cache which owns the collections
18
and can be filled concurrently. The container itself maintains a bit mask to identify which
19
collections can be accessed from this container. It also maintains a wait list which records
20
uncompleted objects that were added to the container. When a complete collection is
21
requested the wait-list is processed, locking the thread until all elements are completed.
22
The intention of this is to delay thread locking until the last possible moment and thus
23
hopefully avoid it altogether.
24
Random access is fast since it takes a direct index to the external cache element.
25
Ordered iteration is also fast after the lazily initialised collection is constructed.
26
*/
27
class
InternalOnline
final :
public
I_InternalIDC
{
28
public
:
29
InternalOnline
(
EventContainers::IdentifiableCacheBase
*cache);
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
;
36
virtual
bool
tryAddFromCache
(
IdentifierHash
hashId,
EventContainers::IDC_WriteHandleBase
&
lock
)
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
;
50
private
:
51
EventContainers::IdentifiableCacheBase
*
m_cacheLink
;
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
;
55
mutable
IdentifierMask
m_mask
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
lock
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
I_InternalIDC.h
IdentifierMask.h
checker_macros.h
Define macros for attributes used to control the static checker.
EventContainers::IDC_WriteHandleBase
Definition
IDC_WriteHandleBase.h:13
EventContainers::I_InternalIDC
Definition
I_InternalIDC.h:35
EventContainers::I_InternalIDC::InternalConstItr
std::vector< hashPair >::const_iterator InternalConstItr
Definition
I_InternalIDC.h:38
EventContainers::IdentifiableCacheBase
Definition
IdentifiableCacheBase.h:23
EventContainers::IdentifierMask
A class for a dynamic bit mask specialised for fast, ordered iteration using the forEachSetBit method...
Definition
IdentifierMask.h:17
EventContainers::InternalOnline::getAllCurrentHashes
virtual std::vector< IdentifierHash > getAllCurrentHashes() const override
Definition
InternalOnline.cxx:94
EventContainers::InternalOnline::~InternalOnline
virtual ~InternalOnline()=default
EventContainers::InternalOnline::indexFind
virtual InternalConstItr indexFind(IdentifierHash hashId) const override
Definition
InternalOnline.cxx:37
EventContainers::InternalOnline::ATLAS_THREAD_SAFE
std::vector< IdentifierHash > m_waitlist ATLAS_THREAD_SAFE
Definition
InternalOnline.h:52
EventContainers::InternalOnline::addLock
virtual StatusCode addLock(IdentifierHash hashId, const void *ptr) override
Definition
InternalOnline.cxx:146
EventContainers::InternalOnline::insert
virtual bool insert(IdentifierHash hashId, const void *ptr) override
Definition
InternalOnline.cxx:131
EventContainers::InternalOnline::findIndexPtr
virtual const void * findIndexPtr(IdentifierHash hashId) const noexcept override
Definition
InternalOnline.cxx:138
EventContainers::InternalOnline::wait
virtual void wait() const override
Definition
InternalOnline.cxx:44
EventContainers::InternalOnline::cleanUp
virtual void cleanUp(deleter_f *) noexcept override
Definition
InternalOnline.cxx:164
EventContainers::InternalOnline::resetMask
void resetMask()
Definition
InternalOnline.cxx:109
EventContainers::InternalOnline::tryAddFromCache
virtual bool tryAddFromCache(IdentifierHash hashId, EventContainers::IDC_WriteHandleBase &lock) override
Definition
InternalOnline.cxx:69
EventContainers::InternalOnline::fullSize
virtual size_t fullSize() const noexcept override
Definition
InternalOnline.h:41
EventContainers::InternalOnline::fetchOrCreate
virtual StatusCode fetchOrCreate(IdentifierHash hashId) override
Definition
InternalOnline.cxx:116
EventContainers::InternalOnline::destructor
virtual void destructor(deleter_f *) noexcept override
Definition
InternalOnline.cxx:160
EventContainers::InternalOnline::removeCollection
virtual void * removeCollection(IdentifierHash hashId) override
Definition
InternalOnline.cxx:156
EventContainers::InternalOnline::getAllHashPtrPair
virtual const std::vector< hashPair > & getAllHashPtrPair() const override
Definition
InternalOnline.cxx:19
EventContainers::InternalOnline::cbegin
virtual InternalConstItr cbegin() const override
Definition
InternalOnline.cxx:32
EventContainers::InternalOnline::InternalOnline
InternalOnline(EventContainers::IdentifiableCacheBase *cache)
Definition
InternalOnline.cxx:16
EventContainers::InternalOnline::cend
virtual InternalConstItr cend() const override
Definition
InternalOnline.cxx:26
EventContainers::InternalOnline::numberOfCollections
virtual size_t numberOfCollections() const override
Definition
InternalOnline.cxx:104
EventContainers::InternalOnline::m_cacheLink
EventContainers::IdentifiableCacheBase * m_cacheLink
Definition
InternalOnline.h:51
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
deleter_f
void deleter_f(const void *p)
Definition
deleter.h:13
const
EventContainers
Definition
T_AthenaPoolCreateFuncs.h:33
Generated on
for ATLAS Offline Software by
1.17.0