ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
IdentifiableContainerMT< T >::IDC_WriteHandle Class Reference

#include <IdentifiableContainerMT.h>

Inheritance diagram for IdentifiableContainerMT< T >::IDC_WriteHandle:
Collaboration diagram for IdentifiableContainerMT< T >::IDC_WriteHandle:

Public Member Functions

 IDC_WriteHandle ()
 
IDC_WriteHandleoperator= (const IDC_WriteHandle &other)=delete
 
 IDC_WriteHandle (const IDC_WriteHandle &other)=delete
 
IDC_WriteHandleoperator= (IDC_WriteHandle &&other) noexcept=delete
 
 IDC_WriteHandle (IDC_WriteHandle &&other)
 
StatusCode addOrDelete (std::unique_ptr< T > ptr)
 
bool alreadyPresent ()
 
bool OnlineAndPresentInAnotherView ()
 This method is to avoid calling an expensive operation in the offline case. More...
 

Static Public Member Functions

static void Swap (IDC_WriteHandle &a, IDC_WriteHandle &b) noexcept
 

Private Member Functions

void LockOn (std::atomic< const void * > *in, mutexPair *pair) noexcept
 
void DropLock () noexcept
 
void ReleaseLock ()
 

Private Attributes

IdentifiableContainerMT< T > * m_IDC_ptr
 
IdentifierHash m_hashId
 
std::atomic< const void * > * m_atomic
 
mutexPair * m_mut
 

Friends

class IdentifiableContainerMT< T >
 

Detailed Description

template<class T>
class IdentifiableContainerMT< T >::IDC_WriteHandle

Definition at line 34 of file IdentifiableContainerMT.h.

Constructor & Destructor Documentation

◆ IDC_WriteHandle() [1/3]

template<class T >
IdentifiableContainerMT< T >::IDC_WriteHandle::IDC_WriteHandle ( )
inline

Definition at line 39 of file IdentifiableContainerMT.h.

◆ IDC_WriteHandle() [2/3]

template<class T >
IdentifiableContainerMT< T >::IDC_WriteHandle::IDC_WriteHandle ( const IDC_WriteHandle other)
delete

◆ IDC_WriteHandle() [3/3]

template<class T >
IdentifiableContainerMT< T >::IDC_WriteHandle::IDC_WriteHandle ( IDC_WriteHandle &&  other)
inline

Definition at line 52 of file IdentifiableContainerMT.h.

52  : IDC_WriteHandle() {
53  Swap(*this, other);
54  }

Member Function Documentation

◆ addOrDelete()

template<class T >
StatusCode IdentifiableContainerMT< T >::IDC_WriteHandle::addOrDelete ( std::unique_ptr< T >  ptr)
inline

Definition at line 56 of file IdentifiableContainerMT.h.

56  {
57  if(ATH_UNLIKELY(m_hashId >= m_IDC_ptr->m_link->fullSize())) return StatusCode::FAILURE;
58  StatusCode sc = m_IDC_ptr->addLock(std::move(ptr), m_hashId);
59  IDC_WriteHandleBase::ReleaseLock();
60  return sc;
61  }

◆ alreadyPresent()

template<class T >
bool IdentifiableContainerMT< T >::IDC_WriteHandle::alreadyPresent ( )
inline

Definition at line 62 of file IdentifiableContainerMT.h.

62 { return m_IDC_ptr->m_link->tryAddFromCache(m_hashId, *this); }

◆ DropLock()

void IDC_WriteHandleBase::DropLock ( )
noexceptinherited

Definition at line 43 of file IDC_WriteHandleBase.cxx.

43  {
44  m_atomic = nullptr;
45 }

◆ LockOn()

void EventContainers::IDC_WriteHandleBase::LockOn ( std::atomic< const void * > *  in,
mutexPair pair 
)
inlinenoexceptinherited

Definition at line 42 of file IDC_WriteHandleBase.h.

42  {
43  m_atomic = in;
44  m_mut = pair;
45  }

◆ OnlineAndPresentInAnotherView()

template<class T >
bool IdentifiableContainerMT< T >::IDC_WriteHandle::OnlineAndPresentInAnotherView ( )
inline

This method is to avoid calling an expensive operation in the offline case.

Definition at line 64 of file IdentifiableContainerMT.h.

64 { return m_IDC_ptr->m_OnlineMode && m_IDC_ptr->m_link->tryAddFromCache(m_hashId, *this); }

◆ operator=() [1/2]

template<class T >
IDC_WriteHandle& IdentifiableContainerMT< T >::IDC_WriteHandle::operator= ( const IDC_WriteHandle other)
delete

◆ operator=() [2/2]

template<class T >
IDC_WriteHandle& IdentifiableContainerMT< T >::IDC_WriteHandle::operator= ( IDC_WriteHandle &&  other)
deletenoexcept

◆ ReleaseLock()

void IDC_WriteHandleBase::ReleaseLock ( )
inherited

Definition at line 17 of file IDC_WriteHandleBase.cxx.

17  {
18  if(m_atomic==nullptr) return;
19 //Convenience declarations
20  const void* waitstate = reinterpret_cast<const void*>(IdentifiableCacheBase::INVALIDflag);
21  const void* ABORTstate = reinterpret_cast<const void*>(IdentifiableCacheBase::ABORTEDflag);
22 
23 //Running code
24  assert(m_atomic->load() != ABORTstate);
25 #ifndef __cpp_lib_atomic_wait
26  typedef std::scoped_lock<decltype(m_mut->mutex)> lockguard;
27  lockguard lk(m_mut->mutex);
28  m_atomic->compare_exchange_strong(waitstate, ABORTstate);
29  m_mut->condition.notify_all();
30 #else
31  //If you have got here the ptr was not set so creation is being aborted
32  //The hash is being set to the aborted flag
33  //I think memory ordering can be relaxed here but to be safe we will use defaults.
34  m_atomic->compare_exchange_strong(waitstate, ABORTstate);
35  //Notify_all to wake up any threads waiting for this hash
36  m_atomic->notify_all();
37 #endif
38 
39  m_atomic = nullptr;
40 }

◆ Swap()

template<class T >
static void IdentifiableContainerMT< T >::IDC_WriteHandle::Swap ( IDC_WriteHandle a,
IDC_WriteHandle b 
)
inlinestaticnoexcept

Definition at line 43 of file IdentifiableContainerMT.h.

43  {
44  if(&a == &b) return;
45  std::swap(a.m_IDC_ptr, b.m_IDC_ptr);
46  std::swap(a.m_hashId, b.m_hashId);
47  std::swap(a.m_atomic, b.m_atomic);
48 #ifndef __cpp_lib_atomic_wait
49  std::swap(a.m_mut, b.m_mut);
50 #endif
51  }

Friends And Related Function Documentation

◆ IdentifiableContainerMT< T >

template<class T >
friend class IdentifiableContainerMT< T >
friend

Definition at line 251 of file IdentifiableContainerMT.h.

Member Data Documentation

◆ m_atomic

std::atomic<const void*>* EventContainers::IDC_WriteHandleBase::m_atomic
protectedinherited

Definition at line 29 of file IDC_WriteHandleBase.h.

◆ m_hashId

template<class T >
IdentifierHash IdentifiableContainerMT< T >::IDC_WriteHandle::m_hashId
private

Definition at line 37 of file IdentifiableContainerMT.h.

◆ m_IDC_ptr

template<class T >
IdentifiableContainerMT<T>* IdentifiableContainerMT< T >::IDC_WriteHandle::m_IDC_ptr
private

Definition at line 36 of file IdentifiableContainerMT.h.

◆ m_mut

mutexPair* EventContainers::IDC_WriteHandleBase::m_mut
protectedinherited

Definition at line 31 of file IDC_WriteHandleBase.h.


The documentation for this class was generated from the following file:
EventContainers::IDC_WriteHandleBase::m_mut
mutexPair * m_mut
Definition: IDC_WriteHandleBase.h:31
IdentifiableContainerMT::IDC_WriteHandle::m_hashId
IdentifierHash m_hashId
Definition: IdentifiableContainerMT.h:37
EventContainers::IdentifiableCacheBase::ABORTEDflag
static constexpr uintptr_t ABORTEDflag
Definition: IdentifiableCacheBase.h:31
IdentifiableContainerMT::IDC_WriteHandle::m_IDC_ptr
IdentifiableContainerMT< T > * m_IDC_ptr
Definition: IdentifiableContainerMT.h:36
EventContainers::IDC_WriteHandleBase::IDC_WriteHandleBase
IDC_WriteHandleBase()
Definition: IDC_WriteHandleBase.h:34
EventContainers::mutexPair::condition
std::condition_variable condition
Definition: IDC_WriteHandleBase.h:20
ATH_UNLIKELY
#define ATH_UNLIKELY(x)
Definition: AthUnlikelyMacros.h:17
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
EventContainers::IDC_WriteHandleBase::m_atomic
std::atomic< const void * > * m_atomic
Definition: IDC_WriteHandleBase.h:29
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
EventContainers::mutexPair::mutex
std::mutex mutex
Definition: IDC_WriteHandleBase.h:21
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
a
TList * a
Definition: liststreamerinfos.cxx:10
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
IdentifiableContainerMT::IDC_WriteHandle::Swap
static void Swap(IDC_WriteHandle &a, IDC_WriteHandle &b) noexcept
Definition: IdentifiableContainerMT.h:43
IdentifiableContainerMT::IDC_WriteHandle::IDC_WriteHandle
IDC_WriteHandle()
Definition: IdentifiableContainerMT.h:39
EventContainers::IdentifiableCacheBase::INVALIDflag
static constexpr uintptr_t INVALIDflag
Definition: IdentifiableCacheBase.h:30