Template Class AtomicRelocatablePointer
Defined in File atomic_relocatable_pointer.hpp
Class Documentation
-
template<typename T>
class AtomicRelocatablePointer minimalistic relocatable pointer that can be written and read atomically and can be stored safely in shared memory. As the basic RelocatablePointer, it must point to something in the same shared memory segment as itself since the internally used offset must be an invariant different across adress spaces. Rationale: the default RelocatablePointer cannot be used in an atomic since the copy ctor is nontrivial.
Public Types
-
using offset_t = std::ptrdiff_t
Public Functions
-
AtomicRelocatablePointer(const T *ptr = nullptr) noexcept
creates an AtomicRelocatablePointer pointing to the same pointee as ptr
- Parameters:
ptr – [in] the pointer whose pointee shall be the same for this
-
AtomicRelocatablePointer(const AtomicRelocatablePointer&) = delete
- Todo:
: can be implemented when needed, note that the offset must be recomputed during the move/copy
-
AtomicRelocatablePointer &operator=(const AtomicRelocatablePointer &other) = delete
-
AtomicRelocatablePointer(AtomicRelocatablePointer &&other) = delete
-
AtomicRelocatablePointer &operator=(AtomicRelocatablePointer &&other) = delete
-
AtomicRelocatablePointer &operator=(const T *ptr) noexcept
assign AtomicRelocatablePointer to point to the same pointee as ptr
Note
minimal set of required operators, can be extended later
- Parameters:
ptr – [in] the pointer whose pointee shall be the same for this
- Returns:
reference to self
-
T *operator->() const noexcept
access to the underlying object in shared memory
- Returns:
a pointer to the underlying object
-
T &operator*() const noexcept
dereferencing operator which returns a reference to the pointee
- Returns:
a reference to the pointee
-
operator T*() const noexcept
converts the AtomicRelocatablePointer to a pointer of type of the underlying object
- Returns:
a pointer of type T pointing to the underlying object
-
using offset_t = std::ptrdiff_t