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;
82 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
88 #if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
99 auto ptr = iOther.m_data.load(std::memory_order_acquire);
101 m_data.store(
new T{*ptr}, std::memory_order_release);
106 auto ptr = iOther.
m_data.load(std::memory_order_acquire);
108 auto ourPtr =m_data.load(std::memory_order_acquire);
109 if( ourPtr !=
nullptr) {
112 m_data.store(
new T{*ptr}, std::memory_order_release);
115 delete m_data.exchange(
nullptr, std::memory_order_acq_rel);
123 delete m_data.load(std::memory_order_acquire);
138 T* expected =
nullptr;
139 if( (retValue = m_data.compare_exchange_strong(expected,iNewValue.get(), std::memory_order_acq_rel)) ) {
150 T*
tmp = m_data.exchange(
nullptr);
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::vector< std::vector< double > > tmp
std::atomic< T * > m_data