[][src]Trait radium::Radium

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

Required methods

fn new(value: T) -> 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 T

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) -> T

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) -> T

Load a value from this object.

Ordering values are ignored by non-atomic types.

See also: AtomicUsize::load.

fn store(&self, value: T, order: Ordering)

Store a value in this object.

Ordering arguments are ignored by non-atomic types.

See also: AtomicUsize::store.

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

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: T, new: T, order: Ordering) -> T

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: T,
    new: T,
    success: Ordering,
    failure: Ordering
) -> Result<T, T>

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: T,
    new: T,
    success: Ordering,
    failure: Ordering
) -> Result<T, T>

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: T, order: Ordering) -> T where
    T: 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: T, order: Ordering) -> T where
    T: 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: T, order: Ordering) -> T where
    T: 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: T, order: Ordering) -> T where
    T: 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: T, order: Ordering) -> T where
    T: 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: T, order: Ordering) -> T where
    T: 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<i8> for AtomicI8[src]

impl Radium<i8> for Cell<i8>[src]

impl Radium<u8> for AtomicU8[src]

impl Radium<u8> for Cell<u8>[src]

impl Radium<i16> for AtomicI16[src]

impl Radium<i16> for Cell<i16>[src]

impl Radium<u16> for AtomicU16[src]

impl Radium<u16> for Cell<u16>[src]

impl Radium<i32> for AtomicI32[src]

impl Radium<i32> for Cell<i32>[src]

impl Radium<u32> for AtomicU32[src]

impl Radium<u32> for Cell<u32>[src]

impl Radium<i64> for AtomicI64[src]

impl Radium<i64> for Cell<i64>[src]

impl Radium<u64> for AtomicU64[src]

impl Radium<u64> for Cell<u64>[src]

impl Radium<isize> for AtomicIsize[src]

impl Radium<isize> for Cell<isize>[src]

impl Radium<usize> for AtomicUsize[src]

impl Radium<usize> for Cell<usize>[src]

impl Radium<bool> for AtomicBool[src]

impl Radium<bool> for Cell<bool>[src]

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

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

Loading content...

Implementors

Loading content...