#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()
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]
Definition at line 204 of file IdentifiableCacheBase.cxx.
205{
207 if(p==nullptr) return std::make_pair(false, nullptr);
208 const void* nul=nullptr;
209 if(
m_vec[hash].compare_exchange_strong(nul, p, std::memory_order_release, std::memory_order_relaxed)){
211 return std::make_pair(true, p);
212 }
214 if(
m_vec[hash].compare_exchange_strong(invalid, p, std::memory_order_release, std::memory_order_acquire)){
217 return std::make_pair(true, p);
218 }
219 return std::make_pair(false, invalid);
220}
void notifyHash(IdentifierHash hash)
const void *const INVALID
◆ add() [2/2]
Definition at line 251 of file IdentifiableCacheBase.cxx.
253{
254 std::pair<bool, const void*>
b =
add(hash,
p.get());
255 if(
b.first)
p.release();
257}
std::pair< bool, const void * > add(IdentifierHash hash, const void *p) noexcept
◆ addLock() [1/2]
Definition at line 223 of file IdentifiableCacheBase.cxx.
224{
225
226 assert(hash <
m_vec.size());
227 if(p==nullptr) return std::make_pair(false, nullptr);
229 if(
m_vec[hash].compare_exchange_strong(invalid, p, std::memory_order_release, std::memory_order_relaxed)){
232 return std::make_pair(true, p);
233 }
234 const void* nul=nullptr;
235 if(
m_vec[hash].compare_exchange_strong(nul, p, std::memory_order_release, std::memory_order_acquire)){
237 return std::make_pair(true, p);
238 }
239 return std::make_pair(false, nul);
240}
◆ addLock() [2/2]
Definition at line 242 of file IdentifiableCacheBase.cxx.
244{
245 std::pair<bool, const void*>
b =
addLock(hash,
p.get());
246 if(
b.first)
p.release();
248}
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{
83 for (
size_t i=0;
i<
s ;
i++) {
84 const void*
p =
m_vec[
i].load(std::memory_order_relaxed);
86 }
87 }
88}
IPayloadDeleter & deleter()
Return a reference to the payload deleter object.
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);
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 176 of file IdentifiableCacheBase.cxx.
176 {
178 for(IdentifierHash hash : hashes){
179 const void*
ptr =
get(hash);
180 if(ptr !=
nullptr)
mask[
hash] =
true;
181 }
182}
const void * get(IdentifierHash hash)
Try to make payload if not there.
◆ find()
Return payload if there, null if not there.
Definition at line 102 of file IdentifiableCacheBase.cxx.
103{
105 const void*
p =
m_vec[
hash].load(std::memory_order_acquire);
107 return nullptr;
109}
◆ findWait()
Retrieve ptr, will wait if there is something in progress.
Definition at line 123 of file IdentifiableCacheBase.cxx.
124{
129}
const void * waitFor(IdentifierHash)
Halts the thread until the require hash is completed or aborted.
◆ fullSize()
| size_t EventContainers::IdentifiableCacheBase::fullSize |
( |
| ) |
const |
|
inline |
◆ get()
Try to make payload if not there.
Definition at line 136 of file IdentifiableCacheBase.cxx.
137{
138
139 const void*
ptr =
nullptr;
141
142 if(
m_vec[hash].compare_exchange_strong(ptr,
INVALID) ) {
143
146 return nullptr;
147 }
150
151 try {
153 }
154 catch (...) {
157 throw;
158 }
160 if(ptr){
163 }else{
165 }
167 }
170 }
171 if(ptr ==
ABORTED)
return nullptr;
174}
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
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 190 of file IdentifiableCacheBase.cxx.
191{
192 std::vector<IdentifierHash> ret;
195 for (
size_t i =0;
i<
s;
i++) {
196 const void*
p =
m_vec[
i].load(std::memory_order_relaxed);
198 ret.push_back (i);
199 }
200 return ret;
201}
◆ 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
47 return 0;
48 }
49
51
52 wait.emplace_back(hash);
53 return 1;
54 }
56 return 2;
57}
◆ waitFor()
Halts the thread until the require hash is completed or aborted.
Definition at line 111 of file IdentifiableCacheBase.cxx.
112{
113 std::atomic<const void*> &myatomic =
m_vec[
hash];
114 const void* item = myatomic.load(std::memory_order_acquire);
115
117 myatomic.wait(item, std::memory_order_relaxed);
118 item = myatomic.load(std::memory_order_acquire);
119 }
120 return item;
121}
◆ InternalOnline
| friend class InternalOnline |
|
friend |
◆ 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: