1 #ifndef DataFormats_Common_AtomicPtrCache_h
2 #define DataFormats_Common_AtomicPtrCache_h
30 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
58 T const*
load()
const;
61 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
62 bool set(std::unique_ptr<T> iNewValue)
const;
80 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
86 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
97 auto ptr = iOther.m_data.load(std::memory_order_acquire);
99 m_data.store(
new T{*ptr}, std::memory_order_release);
104 auto ptr = iOther.
m_data.load(std::memory_order_acquire);
106 auto ourPtr =m_data.load(std::memory_order_acquire);
107 if( ourPtr !=
nullptr) {
110 m_data.store(
new T{*ptr}, std::memory_order_release);
113 delete m_data.exchange(
nullptr, std::memory_order_acq_rel);
121 delete m_data.load(std::memory_order_acquire);
136 T* expected =
nullptr;
137 if( (retValue = m_data.compare_exchange_strong(expected,iNewValue.get(), std::memory_order_acq_rel)) ) {
T const & operator*() const
void reset()
unsets the value and deletes the memory
AtomicPtrCache & operator=(const AtomicPtrCache< T > &)
bool set(std::unique_ptr< T > iNewValue) const
T const * operator->() const
std::atomic< T * > m_data