[][src]Trait radium::Radium

pub trait Radium {
    type Item;
    fn new(value: Self::Item) -> Self;
fn fence(order: Ordering);
fn get_mut(&mut self) -> &mut Self::Item;
fn into_inner(self) -> Self::Item;
fn load(&self, order: Ordering) -> Self::Item;
fn store(&self, value: Self::Item, order: Ordering);
fn swap(&self, value: Self::Item, order: Ordering) -> Self::Item;
fn compare_and_swap(
        &self,
        current: Self::Item,
        new: Self::Item,
        order: Ordering
    ) -> Self::Item;
fn compare_exchange(
        &self,
        current: Self::Item,
        new: Self::Item,
        success: Ordering,
        failure: Ordering
    ) -> Result<Self::Item, Self::Item>;
fn compare_exchange_weak(
        &self,
        current: Self::Item,
        new: Self::Item,
        success: Ordering,
        failure: Ordering
    ) -> Result<Self::Item, Self::Item>;
fn fetch_and(&self, value: Self::Item, order: Ordering) -> Self::Item
    where
        Self::Item: BitOps
;
fn fetch_nand(&self, value: Self::Item, order: Ordering) -> Self::Item
    where
        Self::Item: BitOps
;
fn fetch_or(&self, value: Self::Item, order: Ordering) -> Self::Item
    where
        Self::Item: BitOps
;
fn fetch_xor(&self, value: Self::Item, order: Ordering) -> Self::Item
    where
        Self::Item: BitOps
;
fn fetch_add(&self, value: Self::Item, order: Ordering) -> Self::Item
    where
        Self::Item: NumericOps
;
fn fetch_sub(&self, value: Self::Item, order: Ordering) -> Self::Item
    where
        Self::Item: NumericOps
; }

A maybe-atomic shared mutable fundamental type T.

This trait is implemented by both the atomic wrapper type for T, and by Cell<T>, providing a consistent interface for interacting with the two types.

This trait provides methods predicated on marker traits for the underlying fundamental. Only types which can be viewed as sequences of bits may use the functions for bit-wise arithmetic, and only types which can be used as integers may use the functions for numeric arithmetic. Use of these methods on insufficient underlying types (for example, Radium::fetch_and on an atomic or cell-wrapped pointer) will cause a compiler error.

Associated Types

type Item

Loading content...

Required methods

fn new(value: Self::Item) -> Self

Creates a new value of this type.

fn fence(order: Ordering)

If the underlying value is atomic, calls fence with the given Ordering. Otherwise, does nothing.

fn get_mut(&mut self) -> &mut Self::Item

Returns a mutable reference to the underlying value.

This is safe because the mutable reference to self guarantees that no other references exist to this value.

fn into_inner(self) -> Self::Item

Consumes the wrapper and returns the contained value.

This is safe as passing by value ensures no other references exist.

fn load(&self, order: Ordering) -> Self::Item

Load a value from this object.

Ordering values are ignored by non-atomic types.

See also: AtomicUsize::load.

fn store(&self, value: Self::Item, order: Ordering)

Store a value in this object.

Ordering arguments are ignored by non-atomic types.

See also: AtomicUsize::store.

fn swap(&self, value: Self::Item, order: Ordering) -> Self::Item

Swap with the value stored in this object.

Ordering arguments are ignored by non-atomic types.

See also: AtomicUsize::swap.

fn compare_and_swap(
    &self,
    current: Self::Item,
    new: Self::Item,
    order: Ordering
) -> Self::Item

Stores a value into this object if the currently-stored value is the same as the current value.

The return value is always the previously-stored value. If it is equal to current, then the value was updated with new.

Ordering arguments are ignored by non-atomic types.

See also: AtomicUsize::compare_and_swap.

fn compare_exchange(
    &self,
    current: Self::Item,
    new: Self::Item,
    success: Ordering,
    failure: Ordering
) -> Result<Self::Item, Self::Item>

Stores a value into this object if the currently-stored value is the same as the current value.

The return value is a Result indicating whether the new value was written, and containing the previously-stored value. On success, this value is guaranteed to be equal to current.

Ordering arguments are ignored by non-atomic types.

See also: AtomicUsize::compare_exchange.

fn compare_exchange_weak(
    &self,
    current: Self::Item,
    new: Self::Item,
    success: Ordering,
    failure: Ordering
) -> Result<Self::Item, Self::Item>

Stores a value into this object if the currently-stored value is the same as the current value.

Unlike compare_exchange, this function is allowed to spuriously fail even when the comparison succeeds, which can result in more efficient code on some platforms. The return value is a Result indicating whether the new value was written, and containing the previously-stored value.

Ordering arguments are ignored by non-atomic types.

See also: AtomicUsize::compare_exchange_weak.

fn fetch_and(&self, value: Self::Item, order: Ordering) -> Self::Item where
    Self::Item: BitOps

Performs a bitwise "and" on the currently-stored value and the argument value, and stores the result in self.

Returns the previously-stored value.

Ordering arguments are ignored by non-atomic types.

See also: AtomicUsize::fetch_and.

fn fetch_nand(&self, value: Self::Item, order: Ordering) -> Self::Item where
    Self::Item: BitOps

Performs a bitwise "nand" on the currently-stored value and the argument value, and stores the result in self.

Returns the previously-stored value.

Ordering arguments are ignored by non-atomic types.

See also: AtomicUsize::fetch_nand.

fn fetch_or(&self, value: Self::Item, order: Ordering) -> Self::Item where
    Self::Item: BitOps

Performs a bitwise "or" on the currently-stored value and the argument value, and stores the result in self.

Returns the previously-stored value.

Ordering arguments are ignored by non-atomic types.

See also: AtomicUsize::fetch_or.

fn fetch_xor(&self, value: Self::Item, order: Ordering) -> Self::Item where
    Self::Item: BitOps

Performs a bitwise "xor" on the currently-stored value and the argument value, and stores the result in self.

Returns the previously-stored value.

Ordering arguments are ignored by non-atomic types.

See also: AtomicUsize::fetch_xor.

fn fetch_add(&self, value: Self::Item, order: Ordering) -> Self::Item where
    Self::Item: NumericOps

Adds value to the currently-stored value, wrapping on overflow, and stores the result in self.

Returns the previously-stored value.

Ordering arguments are ignored by non-atomic types.

See also: AtomicUsize::fetch_add.

fn fetch_sub(&self, value: Self::Item, order: Ordering) -> Self::Item where
    Self::Item: NumericOps

Subtracts value from the currently-stored value, wrapping on underflow, and stores the result in self.

Returns the previously-stored value.

Ordering arguments are ignored by non-atomic types.

See also: AtomicUsize::fetch_sub.

Loading content...

Implementations on Foreign Types

impl Radium for AtomicI8[src]

type Item = i8

impl Radium for Cell<i8>[src]

type Item = i8

impl Radium for AtomicU8[src]

type Item = u8

impl Radium for Cell<u8>[src]

type Item = u8

impl Radium for AtomicI16[src]

type Item = i16

impl Radium for Cell<i16>[src]

type Item = i16

impl Radium for AtomicU16[src]

type Item = u16

impl Radium for Cell<u16>[src]

type Item = u16

impl Radium for AtomicI32[src]

type Item = i32

impl Radium for Cell<i32>[src]

type Item = i32

impl Radium for AtomicU32[src]

type Item = u32

impl Radium for Cell<u32>[src]

type Item = u32

impl Radium for AtomicI64[src]

type Item = i64

impl Radium for Cell<i64>[src]

type Item = i64

impl Radium for AtomicU64[src]

type Item = u64

impl Radium for Cell<u64>[src]

type Item = u64

impl Radium for AtomicIsize[src]

type Item = isize

impl Radium for Cell<isize>[src]

type Item = isize

impl Radium for AtomicUsize[src]

type Item = usize

impl Radium for Cell<usize>[src]

type Item = usize

impl Radium for AtomicBool[src]

type Item = bool

impl Radium for Cell<bool>[src]

type Item = bool

impl<T> Radium for AtomicPtr<T>[src]

type Item = *mut T

impl<T> Radium for Cell<*mut T>[src]

type Item = *mut T

Loading content...

Implementors

Loading content...