[][src]Struct reclaim::AtomicMarkedPtr

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

A raw pointer type which can be safely shared between threads, which can store additional information in its lower (unused) bits.

This type has the same in-memory representation as a *mut T. It is mostly identical to AtomicPtr, except that all of its methods involve a MarkedPtr instead of *mut T.

Methods

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

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

Creates a new & unmarked null pointer.

impl<T, N: Unsigned> AtomicMarkedPtr<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 new(ptr: MarkedPtr<T, N>) -> Self[src]

Creates a new AtomicMarkedPtr.

pub fn into_inner(self) -> MarkedPtr<T, N>[src]

Consumes self and returns the inner MarkedPtr

pub fn load(&self, order: Ordering) -> MarkedPtr<T, N>[src]

Loads a value from the pointer.

load takes an Ordering argument which describes the memory ordering of this operation. Possible values are SeqCst, Acquire and Relaxed.

Panics

Panics if order is Release or AcqRel.

Examples

use std::sync::atomic::Ordering;

type MarkedPtr<T> = reclaim::MarkedPtr<T, reclaim::typenum::U1>;
type AtomicMarkedPtr<T> = reclaim::AtomicMarkedPtr<T, reclaim::typenum::U1>;

let ptr = &mut 5;
let marked = MarkedPtr::compose(ptr, 0b1);
let atomic = AtomicMarkedPtr::new(marked);

let value = atomic.load(Ordering::Relaxed);
assert_eq!((Some(&mut 5), 0b1), unsafe { value.decompose_mut() });

pub fn store(&self, ptr: MarkedPtr<T, N>, order: Ordering)[src]

Stores a value into the pointer.

store takes an Ordering argument which describes the memory ordering of this operation. Possible values are SeqCst, Release and Relaxed.

Panics

Panics if order is Acquire or AcqRel.

Examples

use std::sync::atomic::Ordering;

type MarkedPtr<T> = reclaim::MarkedPtr<T, reclaim::typenum::U0>;
type AtomicMarkedPtr<T> = reclaim::AtomicMarkedPtr<T, reclaim::typenum::U0>;

let ptr = &mut 5;
let marked = MarkedPtr::new(ptr);
let atomic = AtomicMarkedPtr::new(marked);

let other_marked = MarkedPtr::new(&mut 10);

atomic.store(other_marked, Ordering::Relaxed);

pub fn swap(&self, ptr: MarkedPtr<T, N>, order: Ordering) -> MarkedPtr<T, N>[src]

Stores a value into the pointer, returning the previous value.

pub fn compare_and_swap(
    &self,
    current: MarkedPtr<T, N>,
    new: MarkedPtr<T, N>,
    order: Ordering
) -> MarkedPtr<T, N>
[src]

Stores a value into the pointer if the current value is the same as current.

pub fn compare_exchange(
    &self,
    current: MarkedPtr<T, N>,
    new: MarkedPtr<T, N>,
    success: Ordering,
    failure: Ordering
) -> Result<MarkedPtr<T, N>, MarkedPtr<T, N>>
[src]

Stores a value into the pointer if the current value is the same as current.

pub fn compare_exchange_weak(
    &self,
    current: MarkedPtr<T, N>,
    new: MarkedPtr<T, N>,
    success: Ordering,
    failure: Ordering
) -> Result<MarkedPtr<T, N>, MarkedPtr<T, N>>
[src]

Stores a value into the pointer if the current value is the same as current.

pub fn fetch_and(&self, value: usize, order: Ordering) -> MarkedPtr<T, N>[src]

Bitwise and with the current tag value.

Performs a bitwise and operation on the current tag and the argument value and sets the new value to the result.

Returns the MarkedPtr with the previous tag, the pointer itself can not change. It value is larger than the mask of markable bits of this type it is silently truncated.

fetch_and takes an Ordering argument, which describes the memory ordering of this operation. All orderings modes are possible. Note, that using Acquire makes the store part of this operation Relaxed and using Release makes the load part `Relaxed

pub fn fetch_nand(&self, value: usize, order: Ordering) -> MarkedPtr<T, N>[src]

Bitwise nand with the current tag value.

Performs a bitwise nand operation on the current tag and the argument value and sets the new value to the result.

Returns the MarkedPtr with the previous tag, the pointer itself can not change. It value is larger than the mask of markable bits of this type it is silently truncated.

fetch_nand takes an Ordering argument, which describes the memory ordering of this operation. All orderings modes are possible. Note, that using Acquire makes the store part of this operation Relaxed and using Release makes the load part `Relaxed

pub fn fetch_or(&self, value: usize, order: Ordering) -> MarkedPtr<T, N>[src]

Bitwise or with the current tag value.

Performs a bitwise or operation on the current tag and the argument value and sets the new value to the result.

Returns the MarkedPtr with the previous tag, the pointer itself can not change. It value is larger than the mask of markable bits of this type it is silently truncated.

fetch_or takes an Ordering argument, which describes the memory ordering of this operation. All orderings modes are possible. Note, that using Acquire makes the store part of this operation Relaxed and using Release makes the load part `Relaxed

pub fn fetch_xor(&self, value: usize, order: Ordering) -> MarkedPtr<T, N>[src]

Bitwise xor with the current tag value.

Performs a bitwise xor operation on the current tag and the argument value and sets the new value to the result.

Returns the MarkedPtr with the previous tag, the pointer itself can not change. It value is larger than the mask of markable bits of this type it is silently truncated.

fetch_xor takes an Ordering argument, which describes the memory ordering of this operation. All orderings modes are possible. Note, that using Acquire makes the store part of this operation Relaxed and using Release makes the load part `Relaxed

Trait Implementations

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

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

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

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

impl<T, N> Sync for AtomicMarkedPtr<T, N>[src]

impl<T, N> Send for AtomicMarkedPtr<T, N>[src]

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

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

Auto Trait Implementations

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

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

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

Blanket Implementations

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

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