ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Event
EventContainers
EventContainers
IdentifiableCacheBase.h
Go to the documentation of this file.
1
// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
3
/*
4
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
#ifndef EVENTCONTAINERS_IDENTIFIABLECACHEBASE_H
8
#define EVENTCONTAINERS_IDENTIFIABLECACHEBASE_H
9
10
11
#include "
Identifier/IdentifierHash.h
"
12
#include <memory>
13
#include <mutex>
14
#include <atomic>
15
#include "
EventContainers/IDC_WriteHandleBase.h
"
16
17
18
namespace
EventContainers
{
19
20
21
22
class
IdentifiableCacheBase
23
{
24
25
public
:
26
//here for access from other classes
27
static
constexpr
uintptr_t
INVALIDflag
= UINTPTR_MAX;
28
static
constexpr
uintptr_t
ABORTEDflag
= UINTPTR_MAX-1;
29
30
31
typedef
std::true_type
thread_safe
;
32
33
#include "
EventContainers/deleter.h
"
34
35
struct
IMaker
36
{
37
bool
m_IsReEntrant
=
false
;
38
virtual
~IMaker
() {}
39
virtual
void_unique_ptr
typelessMake
(
IdentifierHash
hash)
const
= 0;
// unique_ptr<T>??
40
};
41
43
const
void
*
find
(
IdentifierHash
hash)
noexcept
;
45
const
void
*
findWait
(
IdentifierHash
hash);
46
48
const
void
*
get
(
IdentifierHash
hash);
49
51
std::vector<IdentifierHash>
ids
();
52
53
std::pair<bool, const void*>
add
(
IdentifierHash
hash,
const
void
* p)
noexcept
;
54
55
// addLock is same as method above except we check for invalid state first,
56
// more optimal for calling using writehandle lock method
57
std::pair<bool, const void*>
addLock
(
IdentifierHash
hash,
const
void
* p)
noexcept
;
58
std::pair<bool, const void*>
addLock
(
IdentifierHash
hash,
void_unique_ptr
p)
noexcept
;
59
std::pair<bool, const void*>
add
(
IdentifierHash
hash,
void_unique_ptr
p)
noexcept
;
60
61
bool
IMakerPresent
()
const
{
return
m_maker
!=
nullptr
; }
62
67
int
tryLock
(
IdentifierHash
,
IDC_WriteHandleBase
&, std::vector<IdentifierHash>&);
68
70
int
itemAborted
(
IdentifierHash
);
71
73
int
itemInProgress
(
IdentifierHash
);
74
76
const
void
*
waitFor
(
IdentifierHash
);
77
79
void
createSet
(
const
std::vector<IdentifierHash>& hashes, std::vector<bool> &mask);
80
81
size_t
fullSize
()
const
{
return
m_vec
.size(); }
83
size_t
numberOfHashes
();
84
85
protected
:
86
IdentifiableCacheBase
(
IdentifierHash
maxHash,
const
IMaker* maker);
87
~IdentifiableCacheBase
();
88
void
clear
(
deleter_f
* deleter);
89
void
cleanUp
(
deleter_f
* deleter);
//Call once before destruction
90
void
notifyHash
(
IdentifierHash
hash);
91
private
:
92
std::vector<std::atomic<const void*> >
m_vec
;
93
friend
class
InternalOnline
;
94
const
IMaker
*
m_maker
;
95
96
typedef
std::mutex
mutex_t
;
97
typedef
std::scoped_lock<mutex_t>
lock_t
;
98
typedef
std::unique_lock<mutex_t>
uniqueLock
;
99
mutex_t
m_mutex
;
101
std::atomic<size_t>
m_currentHashes
;
102
};
103
104
105
}
// namespace EventContainers
106
107
108
#endif
// not EVENTCONTAINERS_IDENTIFIABLECACHEBASE_H
IDC_WriteHandleBase.h
IdentifierHash.h
clear
void clear()
Empty the pool.
EventContainers::IDC_WriteHandleBase
Definition
IDC_WriteHandleBase.h:13
EventContainers::IdentifiableCacheBase::void_unique_ptr
Definition
IdentifiableCacheBase.h:18
EventContainers::IdentifiableCacheBase::m_vec
std::vector< std::atomic< const void * > > m_vec
Definition
IdentifiableCacheBase.h:92
EventContainers::IdentifiableCacheBase::m_currentHashes
std::atomic< size_t > m_currentHashes
Holds the number of valid hashes in container, in concurrent use it is not guaranteed to be up to dat...
Definition
IdentifiableCacheBase.h:101
EventContainers::IdentifiableCacheBase::waitFor
const void * waitFor(IdentifierHash)
Halts the thread until the require hash is completed or aborted.
Definition
IdentifiableCacheBase.cxx:110
EventContainers::IdentifiableCacheBase::numberOfHashes
size_t numberOfHashes()
In a concurrent situation this number isn't necessarily perfectly synchronised with ids()....
Definition
IdentifiableCacheBase.cxx:184
EventContainers::IdentifiableCacheBase::m_maker
const IMaker * m_maker
Definition
IdentifiableCacheBase.h:94
EventContainers::IdentifiableCacheBase::thread_safe
std::true_type thread_safe
Definition
IdentifiableCacheBase.h:31
EventContainers::IdentifiableCacheBase::itemAborted
int itemAborted(IdentifierHash)
Returns 1 is the item has been aborted otherwise 0.
Definition
IdentifiableCacheBase.cxx:89
EventContainers::IdentifiableCacheBase::itemInProgress
int itemInProgress(IdentifierHash)
Returns 1 is the item is inprogress otherwise 0.
Definition
IdentifiableCacheBase.cxx:95
EventContainers::IdentifiableCacheBase::notifyHash
void notifyHash(IdentifierHash hash)
Definition
IdentifiableCacheBase.cxx:130
EventContainers::IdentifiableCacheBase::IMakerPresent
bool IMakerPresent() const
Definition
IdentifiableCacheBase.h:61
EventContainers::IdentifiableCacheBase::m_mutex
mutex_t m_mutex
Definition
IdentifiableCacheBase.h:99
EventContainers::IdentifiableCacheBase::ids
std::vector< IdentifierHash > ids()
In a threaded situation this collection will be valid but will not container hashes later added.
Definition
IdentifiableCacheBase.cxx:189
EventContainers::IdentifiableCacheBase::get
const void * get(IdentifierHash hash)
Try to make payload if not there.
Definition
IdentifiableCacheBase.cxx:135
EventContainers::IdentifiableCacheBase::deleter_f
void deleter_f(const void *p)
Definition
IdentifiableCacheBase.h:14
EventContainers::IdentifiableCacheBase::cleanUp
void cleanUp(deleter_f *deleter)
Definition
IdentifiableCacheBase.cxx:78
EventContainers::IdentifiableCacheBase::addLock
std::pair< bool, const void * > addLock(IdentifierHash hash, const void *p) noexcept
Definition
IdentifiableCacheBase.cxx:222
EventContainers::IdentifiableCacheBase::tryLock
int tryLock(IdentifierHash, IDC_WriteHandleBase &, std::vector< IdentifierHash > &)
Checks if the item is completed if it is not started it extablishes lock (returns 0),...
Definition
IdentifiableCacheBase.cxx:39
EventContainers::IdentifiableCacheBase::ABORTEDflag
static constexpr uintptr_t ABORTEDflag
Definition
IdentifiableCacheBase.h:28
EventContainers::IdentifiableCacheBase::~IdentifiableCacheBase
~IdentifiableCacheBase()
EventContainers::IdentifiableCacheBase::InternalOnline
friend class InternalOnline
Definition
IdentifiableCacheBase.h:93
EventContainers::IdentifiableCacheBase::createSet
void createSet(const std::vector< IdentifierHash > &hashes, std::vector< bool > &mask)
Create a set of hashes, updates an IDC mask as appropriate.
Definition
IdentifiableCacheBase.cxx:175
EventContainers::IdentifiableCacheBase::IdentifiableCacheBase
IdentifiableCacheBase(IdentifierHash maxHash, const IMaker *maker)
Definition
IdentifiableCacheBase.cxx:28
EventContainers::IdentifiableCacheBase::mutex_t
std::mutex mutex_t
Definition
IdentifiableCacheBase.h:96
EventContainers::IdentifiableCacheBase::add
std::pair< bool, const void * > add(IdentifierHash hash, const void *p) noexcept
Definition
IdentifiableCacheBase.cxx:203
EventContainers::IdentifiableCacheBase::uniqueLock
std::unique_lock< mutex_t > uniqueLock
Definition
IdentifiableCacheBase.h:98
EventContainers::IdentifiableCacheBase::fullSize
size_t fullSize() const
Definition
IdentifiableCacheBase.h:81
EventContainers::IdentifiableCacheBase::findWait
const void * findWait(IdentifierHash hash)
Retrieve ptr, will wait if there is something in progress.
Definition
IdentifiableCacheBase.cxx:122
EventContainers::IdentifiableCacheBase::lock_t
std::scoped_lock< mutex_t > lock_t
Definition
IdentifiableCacheBase.h:97
EventContainers::IdentifiableCacheBase::find
const void * find(IdentifierHash hash) noexcept
Return payload if there, null if not there.
Definition
IdentifiableCacheBase.cxx:101
EventContainers::IdentifiableCacheBase::INVALIDflag
static constexpr uintptr_t INVALIDflag
Definition
IdentifiableCacheBase.h:27
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
deleter.h
EventContainers
Definition
T_AthenaPoolCreateFuncs.h:33
EventContainers::IdentifiableCacheBase::IMaker
Definition
IdentifiableCacheBase.h:36
EventContainers::IdentifiableCacheBase::IMaker::typelessMake
virtual void_unique_ptr typelessMake(IdentifierHash hash) const =0
EventContainers::IdentifiableCacheBase::IMaker::~IMaker
virtual ~IMaker()
Definition
IdentifiableCacheBase.h:38
EventContainers::IdentifiableCacheBase::IMaker::m_IsReEntrant
bool m_IsReEntrant
Definition
IdentifiableCacheBase.h:37
Generated on
for ATLAS Offline Software by
1.17.0