Class RelativePointerData
Defined in File relative_pointer_data.hpp
Class Documentation
-
class RelativePointerData
This are the data for a relative pointer. To be able so safely be used in the shared memory and prevent torn writes/reads, the class must not be larger than 64 bits and trivially copy-able.
Public Functions
-
constexpr RelativePointerData() noexcept = default
Default constructed RelativePointerData which is logically equal to a nullptr.
-
constexpr RelativePointerData(id_t id, offset_t offset) noexcept
constructs a RelativePointerData from a given offset and segment id
- Parameters:
id – [in] is the unique id of the segment
offset – [in] is the offset within the segment
-
id_t id() const noexcept
Getter for the id which identifies the segment.
- Returns:
the id which identifies the segment
-
void reset() noexcept
Resets the pointer to a logically nullptr.
-
bool isLogicalNullptr() const noexcept
Checks if the pointer is logically a nullptr.
- Returns:
true if logically a nullptr otherwise false
Public Static Attributes
-
static constexpr id_t ID_RANGE = {std::numeric_limits<id_t>::max()}
Note
the maximum number of available ids
-
static constexpr id_t NULL_POINTER_ID = {ID_RANGE}
Note
this represents the id of a logically nullptr
-
static constexpr offset_t OFFSET_RANGE = {(1ULL << 48U) - 1U}
id_t is 16 bit and the offset consumes the remaining 48 bits -> offset range is 2^48 - 1
-
static constexpr offset_t NULL_POINTER_OFFSET = {OFFSET_RANGE}
Note
this represents the offset of a logically nullptr;
-
static constexpr offset_t MAX_VALID_OFFSET = {OFFSET_RANGE - 1U}
Note
the maximum offset which can be represented
-
static constexpr offset_t LOGICAL_NULLPTR = {NULL_POINTER_OFFSET << 16 | NULL_POINTER_ID}
Note
internal representation of a nullptr
-
constexpr RelativePointerData() noexcept = default