[][src]Struct reclaim::MarkedPtr

pub struct MarkedPtr<T, N> { /* fields omitted */ }

A raw, unsafe pointer type like *mut T in which up to N of the pointer's lower bits can be used to store additional information (the tag).

Note, that the upper bound for N is dictated by the alignment of T. A type with an alignment of 8 (e.g. a usize on 64-bit architectures) can have up to 3 mark bits. Attempts to use types with insufficient alignment will result in a compile- time error.

Methods

impl<T, N> MarkedPtr<T, N>[src]

pub const fn new(ptr: *mut T) -> Self[src]

Creates an unmarked pointer.

pub const fn null() -> Self[src]

Creates a new & unmarked null pointer.

pub const fn cast<U>(self) -> MarkedPtr<U, N>[src]

Cast to a pointer of another type.

pub const fn from_usize(val: usize) -> Self[src]

Creates a marked pointer from the numeric representation of a potentially marked pointer.

impl<T, N: Unsigned> MarkedPtr<T, N>[src]

pub const MARK_BITS: usize[src]

The number of available mark bits for this type.

pub const MARK_MASK: usize[src]

The bitmask for the lower markable bits.

pub const POINTER_MASK: usize[src]

The bitmask for the higher pointer bits.

pub fn into_usize(self) -> usize[src]

Returns the numeric representation of the pointer with its tag.

pub fn into_ptr(self) -> *mut T[src]

Returns the inner pointer as is, meaning potential tags are not stripped.

pub fn compose(ptr: *mut T, tag: usize) -> Self[src]

Composes a new marked pointer from a raw unmarked pointer and a tag value.

pub fn convert<M: Unsigned>(other: MarkedPtr<T, M>) -> Self where
    N: IsGreaterOrEqual<M, Output = True>, 
[src]

Converts a marked pointer with M potential mark bits to the same marked pointer with N potential mark bits, requires that N >= M.

pub fn clear_tag(self) -> Self[src]

Clears the tag of self and returns the same but untagged pointer.

pub fn with_tag(self, tag: usize) -> Self[src]

Clears the tag of self and replaces it with tag.

pub fn decompose(self) -> (*mut T, usize)[src]

Decomposes the marked pointer, returning the separated raw pointer and its tag.

pub fn decompose_ptr(self) -> *mut T[src]

Decomposes the marked pointer, returning only the separated raw pointer.

pub fn decompose_tag(self) -> usize[src]

Decomposes the marked pointer, returning only the separated tag.

pub unsafe fn decompose_ref<'a>(self) -> (Option<&'a T>, usize)[src]

Decomposes the marked pointer, returning an optional reference and the separated tag.

In case the pointer stripped of its tag is null, None is returned as part of the tuple. Otherwise, the reference is wrapped in a Some.

Safety

While this method and its mutable counterpart are useful for null-safety, it is important to note that this is still an unsafe operation because the returned value could be pointing to invalid memory.

Additionally, the lifetime 'a returned is arbitrarily chosen and does not necessarily reflect the actual lifetime of the data.

pub unsafe fn decompose_mut<'a>(self) -> (Option<&'a mut T>, usize)[src]

Decomposes the marked pointer returning an optional mutable reference and the separated tag.

In case the pointer stripped of its tag is null, None is returned as part of the tuple. Otherwise, the mutable reference is wrapped in a Some.

Safety

As with decompose_ref, this is unsafe because it cannot verify the validity of the returned pointer, nor can it ensure that the lifetime 'a returned is indeed a valid lifetime for the contained data.

pub unsafe fn as_ref<'a>(self) -> Option<&'a T>[src]

Decomposes the marked pointer, returning an optional reference and discarding the tag.

Safety

The same caveats as with decompose_ref apply for this method as well.

pub unsafe fn as_mut<'a>(self) -> Option<&'a mut T>[src]

Decomposes the marked pointer, returning an optional mutable reference and discarding the tag.

Safety

The same caveats as with decompose_mut apply for this method as well.

pub fn is_null(self) -> bool[src]

Returns true if the pointer is null (regardless of the tag).

Trait Implementations

impl<T, N: Unsigned> From<MarkedPtr<T, N>> for AtomicMarkedPtr<T, N>[src]

impl<T, N: Unsigned> From<*const T> for MarkedPtr<T, N>[src]

impl<T, N: Unsigned> From<*mut T> for MarkedPtr<T, N>[src]

impl<'a, T, N: Unsigned> From<&'a T> for MarkedPtr<T, N>[src]

impl<'a, T, N: Unsigned> From<&'a mut T> for MarkedPtr<T, N>[src]

impl<T, N: Unsigned> From<NonNull<T>> for MarkedPtr<T, N>[src]

impl<T, N: Unsigned> From<(*mut T, usize)> for MarkedPtr<T, N>[src]

impl<T, N: Unsigned> From<(*const T, usize)> for MarkedPtr<T, N>[src]

impl<T, N> PartialEq<MarkedPtr<T, N>> for MarkedNonNull<T, N>[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl<T, N> PartialEq<MarkedPtr<T, N>> for MarkedPtr<T, N>[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl<T, N> PartialEq<MarkedNonNull<T, N>> for MarkedPtr<T, N>[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl<T, N> Clone for MarkedPtr<T, N>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<T, N: Unsigned> Default for MarkedPtr<T, N>[src]

impl<T, N> PartialOrd<MarkedPtr<T, N>> for MarkedNonNull<T, N>[src]

#[must_use] fn lt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use] fn le(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use] fn gt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use] fn ge(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<T, N> PartialOrd<MarkedPtr<T, N>> for MarkedPtr<T, N>[src]

#[must_use] fn lt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use] fn le(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use] fn gt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use] fn ge(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<T, N> PartialOrd<MarkedNonNull<T, N>> for MarkedPtr<T, N>[src]

#[must_use] fn lt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use] fn le(&self, other: &Rhs) -> bool1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use] fn gt(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use] fn ge(&self, other: &Rhs) -> bool1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl<T, N> Copy for MarkedPtr<T, N>[src]

impl<T, N: Unsigned> Debug for MarkedPtr<T, N>[src]

impl<T, N: Unsigned> TryFrom<MarkedPtr<T, N>> for MarkedNonNull<T, N>[src]

type Error = InvalidNullError

The type returned in the event of a conversion error.

impl<T, N: Unsigned> Pointer for MarkedPtr<T, N>[src]

Auto Trait Implementations

impl<T, N> Unpin for MarkedPtr<T, N> where
    N: Unpin,
    T: Unpin

impl<T, N> !Sync for MarkedPtr<T, N>

impl<T, N> !Send for MarkedPtr<T, N>

impl<T, N> RefUnwindSafe for MarkedPtr<T, N> where
    N: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, N> UnwindSafe for MarkedPtr<T, N> where
    N: UnwindSafe,
    T: RefUnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T[src]

type Output = T

Should always be Self