#include <IdentifiableCacheBase.h>
Inherited by EventContainers::IdentifiableCache< InDetRawDataCollection< PixelRDORawData > >, EventContainers::IdentifiableCache< InDetRawDataCollection< SCT_RDORawData > >, EventContainers::IdentifiableCache< InDetRawDataCollection< TRT_RDORawData > >, EventContainers::IdentifiableCache< PixelClusterCollection >, EventContainers::IdentifiableCache< SCT_ClusterCollection >, EventContainers::IdentifiableCache< TRT_DriftCircleCollection >, EventContainers::IdentifiableCache< CscRawDataCollection >, EventContainers::IdentifiableCache< MdtCsm >, EventContainers::IdentifiableCache< Muon::MM_RawDataCollection >, EventContainers::IdentifiableCache< RpcPad >, EventContainers::IdentifiableCache< Muon::STGC_RawDataCollection >, EventContainers::IdentifiableCache< TgcL1Rdo >, EventContainers::IdentifiableCache< TgcRdo >, EventContainers::IdentifiableCache< Muon::CscPrepDataCollection >, EventContainers::IdentifiableCache< Muon::CscStripPrepDataCollection >, EventContainers::IdentifiableCache< Muon::MdtPrepDataCollection >, EventContainers::IdentifiableCache< Muon::RpcPrepDataCollection >, EventContainers::IdentifiableCache< Muon::TgcPrepDataCollection >, EventContainers::IdentifiableCache< Muon::sTgcPrepDataCollection >, EventContainers::IdentifiableCache< Muon::MMPrepDataCollection >, EventContainers::IdentifiableCache< Muon::RpcCoinDataCollection >, EventContainers::IdentifiableCache< Muon::TgcCoinDataCollection >, EventContainers::IdentifiableCache< SpacePointCollection >, and EventContainers::IdentifiableCache< T >.
|
| const void * | find (IdentifierHash hash) noexcept |
| | Return payload if there, null if not there.
|
| const void * | findWait (IdentifierHash hash) |
| | Retrieve ptr, will wait if there is something in progress.
|
| const void * | get (IdentifierHash hash) |
| | Try to make payload if not there.
|
| std::vector< IdentifierHash > | ids () |
| | In a threaded situation this collection will be valid but will not container hashes later added.
|
| std::pair< bool, const void * > | add (IdentifierHash hash, const void *p) noexcept |
| std::pair< bool, const void * > | addLock (IdentifierHash hash, const void *p) noexcept |
| std::pair< bool, const void * > | addLock (IdentifierHash hash, void_unique_ptr p) noexcept |
| std::pair< bool, const void * > | add (IdentifierHash hash, void_unique_ptr p) noexcept |
| bool | IMakerPresent () const |
| int | tryLock (IdentifierHash, IDC_WriteHandleBase &, std::vector< IdentifierHash > &) |
| | Checks if the item is completed if it is not started it extablishes lock (returns 0), If it is started but not completed it adds to wait list (returns 1) If the item is already completed it returns 2 If the item is aborted it does nothing and returns 3.
|
| int | itemAborted (IdentifierHash) |
| | Returns 1 is the item has been aborted otherwise 0.
|
| int | itemInProgress (IdentifierHash) |
| | Returns 1 is the item is inprogress otherwise 0.
|
| const void * | waitFor (IdentifierHash) |
| | Halts the thread until the require hash is completed or aborted.
|
| void | createSet (const std::vector< IdentifierHash > &hashes, std::vector< bool > &mask) |
| | Create a set of hashes, updates an IDC mask as appropriate.
|
| size_t | fullSize () const |
| size_t | numberOfHashes () |
| | In a concurrent situation this number isn't necessarily perfectly synchronised with ids().size()
|
Definition at line 22 of file IdentifiableCacheBase.h.
◆ deleter_f
| typedef void EventContainers::IdentifiableCacheBase::deleter_f(const void *p) |
◆ lock_t
◆ mutex_t
◆ thread_safe
◆ uniqueLock
◆ IdentifiableCacheBase()
| EventContainers::IdentifiableCacheBase::IdentifiableCacheBase |
( |
IdentifierHash | maxHash, |
|
|
const IMaker * | maker ) |
|
protected |
Definition at line 29 of file IdentifiableCacheBase.cxx.
34{
35}
std::vector< std::atomic< const void * > > m_vec
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...
◆ ~IdentifiableCacheBase()
| EventContainers::IdentifiableCacheBase::~IdentifiableCacheBase |
( |
| ) |
|
|
protecteddefault |
◆ add() [1/2]
| std::pair< bool, const void * > EventContainers::IdentifiableCacheBase::add |
( |
IdentifierHash | hash, |
|
|
const void * | p ) |
|
noexcept |
Definition at line 205 of file IdentifiableCacheBase.cxx.
206{
208 if(p==nullptr) return std::make_pair(false, nullptr);
209 const void* nul=nullptr;
210 if(
m_vec[hash].compare_exchange_strong(nul, p, std::memory_order_release, std::memory_order_relaxed)){
212 return std::make_pair(true, p);
213 }
215 if(
m_vec[hash].compare_exchange_strong(invalid, p, std::memory_order_release, std::memory_order_acquire)){
218 return std::make_pair(true, p);
219 }
220 return std::make_pair(false, invalid);
221}
void notifyHash(IdentifierHash hash)
const void *const INVALID
◆ add() [2/2]
Definition at line 252 of file IdentifiableCacheBase.cxx.
254{
255 std::pair<bool, const void*>
b =
add(hash,
p.get());
256 if(
b.first)
p.release();
258}
std::pair< bool, const void * > add(IdentifierHash hash, const void *p) noexcept
◆ addLock() [1/2]
| std::pair< bool, const void * > EventContainers::IdentifiableCacheBase::addLock |
( |
IdentifierHash | hash, |
|
|
const void * | p ) |
|
noexcept |
Definition at line 224 of file IdentifiableCacheBase.cxx.
225{
226
227 assert(hash <
m_vec.size());
228 if(p==nullptr) return std::make_pair(false, nullptr);
230 if(
m_vec[hash].compare_exchange_strong(invalid, p, std::memory_order_release, std::memory_order_relaxed)){
233 return std::make_pair(true, p);
234 }
235 const void* nul=nullptr;
236 if(
m_vec[hash].compare_exchange_strong(nul, p, std::memory_order_release, std::memory_order_acquire)){
238 return std::make_pair(true, p);
239 }
240 return std::make_pair(false, nul);
241}
◆ addLock() [2/2]
Definition at line 243 of file IdentifiableCacheBase.cxx.
245{
246 std::pair<bool, const void*>
b =
addLock(hash,
p.get());
247 if(
b.first)
p.release();
249}
std::pair< bool, const void * > addLock(IdentifierHash hash, const void *p) noexcept
◆ cleanUp()
| void EventContainers::IdentifiableCacheBase::cleanUp |
( |
deleter_f * | deleter | ) |
|
|
protected |
Definition at line 79 of file IdentifiableCacheBase.cxx.
80{
81 std::atomic_thread_fence(std::memory_order_acquire);
84 for (
size_t i=0;
i<
s ;
i++) {
85 const void*
p =
m_vec[
i].load(std::memory_order_relaxed);
86 if(p && p <
ABORTED) deleter (p);
87 }
88 }
89}
const void *const ABORTED
◆ clear()
| void EventContainers::IdentifiableCacheBase::clear |
( |
deleter_f * | deleter | ) |
|
|
protected |
Definition at line 60 of file IdentifiableCacheBase.cxx.
61{
64 for (
size_t i=0;
i<
s ;
i++) {
65 const void*
ptr =
m_vec[
i].load(std::memory_order_relaxed);
66 m_vec[
i].store(
nullptr, std::memory_order_relaxed);
68 deleter (ptr);
69 }
70 }
72 }else{
73 for (
size_t i=0;
i<
s ;
i++)
m_vec[i].
store(
nullptr, std::memory_order_relaxed);
74 }
75}
◆ createSet()
| void EventContainers::IdentifiableCacheBase::createSet |
( |
const std::vector< IdentifierHash > & | hashes, |
|
|
std::vector< bool > & | mask ) |
Create a set of hashes, updates an IDC mask as appropriate.
Definition at line 177 of file IdentifiableCacheBase.cxx.
177 {
179 for(IdentifierHash hash : hashes){
180 const void*
ptr =
get(hash);
181 if(ptr !=
nullptr)
mask[
hash] =
true;
182 }
183}
const void * get(IdentifierHash hash)
Try to make payload if not there.
◆ find()
| const void * EventContainers::IdentifiableCacheBase::find |
( |
IdentifierHash | hash | ) |
|
|
noexcept |
Return payload if there, null if not there.
Definition at line 103 of file IdentifiableCacheBase.cxx.
104{
106 const void*
p =
m_vec[
hash].load(std::memory_order_acquire);
108 return nullptr;
110}
◆ findWait()
| const void * EventContainers::IdentifiableCacheBase::findWait |
( |
IdentifierHash | hash | ) |
|
Retrieve ptr, will wait if there is something in progress.
Definition at line 124 of file IdentifiableCacheBase.cxx.
125{
130}
const void * waitFor(IdentifierHash)
Halts the thread until the require hash is completed or aborted.
◆ fullSize()
| size_t EventContainers::IdentifiableCacheBase::fullSize |
( |
| ) |
const |
|
inline |
◆ get()
| const void * EventContainers::IdentifiableCacheBase::get |
( |
IdentifierHash | hash | ) |
|
Try to make payload if not there.
Definition at line 137 of file IdentifiableCacheBase.cxx.
138{
139
140 const void*
ptr =
nullptr;
142
143 if(
m_vec[hash].compare_exchange_strong(ptr,
INVALID) ) {
144
147 return nullptr;
148 }
150 if(!
m_maker->m_IsReEntrant) lock.lock();
151
152 try {
154 }
155 catch (...) {
156
158 throw;
159 }
161 if(ptr){
164 }else{
166 }
168 }
171 }
172 if(ptr ==
ABORTED)
return nullptr;
175}
std::unique_lock< mutex_t > uniqueLock
◆ ids()
| std::vector< IdentifierHash > EventContainers::IdentifiableCacheBase::ids |
( |
| ) |
|
In a threaded situation this collection will be valid but will not container hashes later added.
Definition at line 191 of file IdentifiableCacheBase.cxx.
192{
193 std::vector<IdentifierHash> ret;
196 for (
size_t i =0;
i<
s;
i++) {
197 const void*
p =
m_vec[
i].load(std::memory_order_relaxed);
199 ret.push_back (i);
200 }
201 return ret;
202}
◆ IMakerPresent()
| bool EventContainers::IdentifiableCacheBase::IMakerPresent |
( |
| ) |
const |
|
inline |
◆ itemAborted()
| int EventContainers::IdentifiableCacheBase::itemAborted |
( |
IdentifierHash | hash | ) |
|
◆ itemInProgress()
| int EventContainers::IdentifiableCacheBase::itemInProgress |
( |
IdentifierHash | hash | ) |
|
◆ notifyHash()
| void EventContainers::IdentifiableCacheBase::notifyHash |
( |
IdentifierHash | hash | ) |
|
|
protected |
◆ numberOfHashes()
| size_t EventContainers::IdentifiableCacheBase::numberOfHashes |
( |
| ) |
|
◆ tryLock()
Checks if the item is completed if it is not started it extablishes lock (returns 0), If it is started but not completed it adds to wait list (returns 1) If the item is already completed it returns 2 If the item is aborted it does nothing and returns 3.
Definition at line 40 of file IdentifiableCacheBase.cxx.
40 {
41 const void *ptr1 =nullptr;
42
43 if(
m_vec[hash].compare_exchange_strong(ptr1,
INVALID, std::memory_order_relaxed, std::memory_order_relaxed)){
44
45
46 lock.LockOn(&
m_vec[hash]);
47 return 0;
48 }
49
51
52 wait.emplace_back(hash);
53 return 1;
54 }
56 return 2;
57}
◆ waitFor()
| const void * EventContainers::IdentifiableCacheBase::waitFor |
( |
IdentifierHash | hash | ) |
|
Halts the thread until the require hash is completed or aborted.
Definition at line 112 of file IdentifiableCacheBase.cxx.
113{
114 std::atomic<const void*> &myatomic =
m_vec[
hash];
115 const void*
item = myatomic.load(std::memory_order_acquire);
116
118 myatomic.wait(item, std::memory_order_relaxed);
119 item = myatomic.load(std::memory_order_acquire);
120 }
122}
◆ InternalOnline
◆ ABORTEDflag
| uintptr_t EventContainers::IdentifiableCacheBase::ABORTEDflag = UINTPTR_MAX-1 |
|
staticconstexpr |
◆ INVALIDflag
| uintptr_t EventContainers::IdentifiableCacheBase::INVALIDflag = UINTPTR_MAX |
|
staticconstexpr |
◆ m_currentHashes
| std::atomic<size_t> EventContainers::IdentifiableCacheBase::m_currentHashes |
|
private |
Holds the number of valid hashes in container, in concurrent use it is not guaranteed to be up to date.
Definition at line 101 of file IdentifiableCacheBase.h.
◆ m_maker
| const IMaker* EventContainers::IdentifiableCacheBase::m_maker |
|
private |
◆ m_mutex
| mutex_t EventContainers::IdentifiableCacheBase::m_mutex |
|
private |
◆ m_vec
| std::vector<std::atomic<const void*> > EventContainers::IdentifiableCacheBase::m_vec |
|
private |
The documentation for this class was generated from the following files: