Skip to content

iox::rp::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. More...

#include <atomic_relocatable_pointer.hpp>

Public Types🔗

Name
using std::ptrdiff_t offset_t

Public Functions🔗

Name
AtomicRelocatablePointer(const T * ptr =nullptr)
creates an AtomicRelocatablePointer pointing to the same pointee as ptr
AtomicRelocatablePointer(const AtomicRelocatablePointer & )
AtomicRelocatablePointer & operator=(const AtomicRelocatablePointer & other)
AtomicRelocatablePointer(AtomicRelocatablePointer && other)
AtomicRelocatablePointer & operator=(AtomicRelocatablePointer && other)
AtomicRelocatablePointer & operator=(const T * ptr)
assign AtomicRelocatablePointer to point to the same pointee as ptr
T * operator->() const
access to the underlying object in shared memory
T & operator*() const
dereferencing operator which returns a reference to the pointee
operator T*() const
converts the AtomicRelocatablePointer to a pointer of type of the underlying object

Public Attributes🔗

Name
constexpr offset_t NULL_POINTER_OFFSET

Detailed Description🔗

template <typename T >
class iox::rp::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 Documentation🔗

using offset_t🔗

using iox::rp::AtomicRelocatablePointer< T >::offset_t =  std::ptrdiff_t;

Public Functions Documentation🔗

function AtomicRelocatablePointer🔗

inline AtomicRelocatablePointer(
    const T * ptr =nullptr
)

creates an AtomicRelocatablePointer pointing to the same pointee as ptr

Parameters:

  • ptr the pointer whose pointee shall be the same for this

function AtomicRelocatablePointer🔗

AtomicRelocatablePointer(
    const AtomicRelocatablePointer & 
)

Todo: : can be implemented when needed, note that the offset must be recomputed during the move/copy

function operator=🔗

AtomicRelocatablePointer & operator=(
    const AtomicRelocatablePointer & other
)

function AtomicRelocatablePointer🔗

AtomicRelocatablePointer(
    AtomicRelocatablePointer && other
)

function operator=🔗

AtomicRelocatablePointer & operator=(
    AtomicRelocatablePointer && other
)

function operator=🔗

inline AtomicRelocatablePointer & operator=(
    const T * ptr
)

assign AtomicRelocatablePointer to point to the same pointee as ptr

Parameters:

  • ptr the pointer whose pointee shall be the same for this

Return: reference to self

Note: minimal set of required operators, can be extended later

function operator->🔗

inline T * operator->() const

access to the underlying object in shared memory

Return: a pointer to the underlying object

function operator*🔗

inline T & operator*() const

dereferencing operator which returns a reference to the pointee

Return: a reference to the pointee

function operator T*🔗

inline operator T*() const

converts the AtomicRelocatablePointer to a pointer of type of the underlying object

Return: a pointer of type T pointing to the underlying object

Public Attributes Documentation🔗

variable NULL_POINTER_OFFSET🔗

static constexpr offset_t NULL_POINTER_OFFSET = std::numeric_limits<offset_t>::max();

Updated on 31 May 2022 at 15:29:15 CEST