[][src]Trait atomic_traits::Atomic

pub trait Atomic {
    type Type;
    fn new(v: Self::Type) -> Self;
fn get_mut(&mut self) -> &mut Self::Type;
fn into_inner(self) -> Self::Type;
fn load(&self, order: Ordering) -> Self::Type;
fn store(&self, val: Self::Type, order: Ordering);
fn swap(&self, val: Self::Type, order: Ordering) -> Self::Type;
fn compare_and_swap(
        &self,
        current: Self::Type,
        new: Self::Type,
        order: Ordering
    ) -> Self::Type;
fn compare_exchange(
        &self,
        current: Self::Type,
        new: Self::Type,
        success: Ordering,
        failure: Ordering
    ) -> Result<Self::Type, Self::Type>;
fn compare_exchange_weak(
        &self,
        current: Self::Type,
        new: Self::Type,
        success: Ordering,
        failure: Ordering
    ) -> Result<Self::Type, Self::Type>; }

Generic atomic types

Associated Types

type Type

The underlying type

Loading content...

Required methods

fn new(v: Self::Type) -> Self

Creates a new atomic type.

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

Returns a mutable reference to the underlying type.

fn into_inner(self) -> Self::Type

Consumes the atomic and returns the contained value.

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

Loads a value from the atomic type.

fn store(&self, val: Self::Type, order: Ordering)

Stores a value into the atomic type.

fn swap(&self, val: Self::Type, order: Ordering) -> Self::Type

Stores a value into the atomic type, returning the previous value.

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

Stores a value into the atomic type if the current value is the same as the current value.

The return value is always the previous value. If it is equal to current, then the value was updated.

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

Stores a value into the atomic type if the current value is the same as the current value.

The return value is a result indicating whether the new value was written and containing the previous value. On success this value is guaranteed to be equal to current.

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

Stores a value into the atomic type if the current 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 previous value.

Loading content...

Implementations on Foreign Types

impl Atomic for AtomicBool[src]

type Type = bool

impl Atomic for AtomicIsize[src]

type Type = isize

impl Atomic for AtomicUsize[src]

type Type = usize

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

type Type = *mut T

impl Atomic for AtomicI8[src]

type Type = i8

impl Atomic for AtomicI16[src]

type Type = i16

impl Atomic for AtomicI32[src]

type Type = i32

impl Atomic for AtomicI64[src]

type Type = i64

impl Atomic for AtomicU8[src]

type Type = u8

impl Atomic for AtomicU16[src]

type Type = u16

impl Atomic for AtomicU32[src]

type Type = u32

impl Atomic for AtomicU64[src]

type Type = u64

Loading content...

Implementors

Loading content...