#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 28 of file IdentifiableCacheBase.cxx.
33{
34}
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 203 of file IdentifiableCacheBase.cxx.
204{
205 if (hash >=
m_vec.size()) [[
unlikely]]
return std::make_pair(
false,
nullptr);
206 if(p==nullptr) return std::make_pair(false, nullptr);
207 const void* nul=nullptr;
208 if(
m_vec[hash].compare_exchange_strong(nul, p, std::memory_order_release, std::memory_order_relaxed)){
210 return std::make_pair(true, p);
211 }
213 if(
m_vec[hash].compare_exchange_strong(invalid, p, std::memory_order_release, std::memory_order_acquire)){
216 return std::make_pair(true, p);
217 }
218 return std::make_pair(false, invalid);
219}
void notifyHash(IdentifierHash hash)
const void *const INVALID
◆ add() [2/2]
Definition at line 250 of file IdentifiableCacheBase.cxx.
252{
253 std::pair<bool, const void*>
b =
add(hash,
p.get());
254 if(
b.first)
p.release();
256}
std::pair< bool, const void * > add(IdentifierHash hash, const void *p) noexcept
◆ addLock() [1/2]
Definition at line 222 of file IdentifiableCacheBase.cxx.
223{
224
225 assert(hash <
m_vec.size());
226 if(p==nullptr) return std::make_pair(false, nullptr);
228 if(
m_vec[hash].compare_exchange_strong(invalid, p, std::memory_order_release, std::memory_order_relaxed)){
231 return std::make_pair(true, p);
232 }
233 const void* nul=nullptr;
234 if(
m_vec[hash].compare_exchange_strong(nul, p, std::memory_order_release, std::memory_order_acquire)){
236 return std::make_pair(true, p);
237 }
238 return std::make_pair(false, nul);
239}
◆ addLock() [2/2]
Definition at line 241 of file IdentifiableCacheBase.cxx.
243{
244 std::pair<bool, const void*>
b =
addLock(hash,
p.get());
245 if(
b.first)
p.release();
247}
std::pair< bool, const void * > addLock(IdentifierHash hash, const void *p) noexcept
◆ cleanUp()
| void EventContainers::IdentifiableCacheBase::cleanUp |
( |
deleter_f * | deleter | ) |
|
|
protected |
Definition at line 78 of file IdentifiableCacheBase.cxx.
79{
82 for (
size_t i=0;
i<
s ;
i++) {
83 const void*
p =
m_vec[
i].load(std::memory_order_relaxed);
85 }
86 }
87}
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 59 of file IdentifiableCacheBase.cxx.
60{
63 for (
size_t i=0;
i<
s ;
i++) {
64 const void*
ptr =
m_vec[
i].load(std::memory_order_relaxed);
65 m_vec[
i].store(
nullptr, std::memory_order_relaxed);
68 }
69 }
71 }else{
72 for (
size_t i=0;
i<
s ;
i++)
m_vec[i].
store(
nullptr, std::memory_order_relaxed);
73 }
74}
◆ 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 175 of file IdentifiableCacheBase.cxx.
175 {
177 for(IdentifierHash hash : hashes){
178 const void*
ptr =
get(hash);
179 if(ptr !=
nullptr)
mask[
hash] =
true;
180 }
181}
const void * get(IdentifierHash hash)
Try to make payload if not there.
◆ find()
Return payload if there, null if not there.
Definition at line 101 of file IdentifiableCacheBase.cxx.
102{
104 const void*
p =
m_vec[
hash].load(std::memory_order_acquire);
106 return nullptr;
108}
◆ findWait()
Retrieve ptr, will wait if there is something in progress.
Definition at line 122 of file IdentifiableCacheBase.cxx.
123{
128}
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 135 of file IdentifiableCacheBase.cxx.
136{
137
138 const void*
ptr =
nullptr;
140
141 if(
m_vec[hash].compare_exchange_strong(ptr,
INVALID) ) {
142
145 return nullptr;
146 }
149
150 try {
152 }
153 catch (...) {
156 throw;
157 }
159 if(ptr){
162 }else{
164 }
166 }
169 }
170 if(ptr ==
ABORTED)
return nullptr;
173}
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 189 of file IdentifiableCacheBase.cxx.
190{
191 std::vector<IdentifierHash> ret;
194 for (
size_t i =0;
i<
s;
i++) {
195 const void*
p =
m_vec[
i].load(std::memory_order_relaxed);
197 ret.push_back (i);
198 }
199 return ret;
200}
◆ 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 39 of file IdentifiableCacheBase.cxx.
39 {
40 const void *ptr1 =nullptr;
41
42 if(
m_vec[hash].compare_exchange_strong(ptr1,
INVALID, std::memory_order_relaxed, std::memory_order_relaxed)){
43
44
46 return 0;
47 }
48
50
51 wait.emplace_back(hash);
52 return 1;
53 }
55 return 2;
56}
◆ waitFor()
Halts the thread until the require hash is completed or aborted.
Definition at line 110 of file IdentifiableCacheBase.cxx.
111{
112 std::atomic<const void*> &myatomic =
m_vec[
hash];
113 const void* item = myatomic.load(std::memory_order_acquire);
114
116 myatomic.wait(item, std::memory_order_relaxed);
117 item = myatomic.load(std::memory_order_acquire);
118 }
119 return item;
120}
◆ 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: