13#ifndef CXXUTILS_CACHEDPOINTER_H
14#define CXXUTILS_CACHEDPOINTER_H
21#if ATOMIC_POINTER_LOCK_FREE != 2
22# error Code assumes lock-free atomic pointers; see comments below.
98 mutable std::atomic<pointer_t>
m_a;
CachedPointer & operator=(const CachedPointer &other) noexcept
Assignment.
void set(pointer_t elt) const
Set the element, assuming it is currently null.
pointer_t get() const
Return the current value of the element.
CachedPointer()
Default constructor. Sets the element to null.
const T * pointer_t
The stored pointer type.
CachedPointer(pointer_t elt)
Constructor from an element.
std::atomic< pointer_t > m_a
The cached element, both directly and as an atomic (recall that this is a union).
const pointer_t * ptr() const
Return a pointer to the cached element.
CachedPointer(const CachedPointer &other) noexcept
Copy constructor.
void store(pointer_t elt)
Store a new value to the element.