pub trait AtomicStorage: Sized + Send + Sync + AtomicStorageBase {
    const ZERO: Self::Underlying;

    fn new(v: Self::Underlying) -> Self;
    fn into_inner(self) -> Self::Underlying;
    fn get_mut(&mut self) -> &mut Self::Underlying;
    fn load(&self, _order: Ordering) -> Self::Underlying;
    fn store(&self, val: Self::Underlying, order: Ordering);
    fn swap(&self, val: Self::Underlying, order: Ordering) -> Self::Underlying;
    fn compare_exchange(
        &self,
        current: Self::Underlying,
        new: Self::Underlying,
        success: Ordering,
        failure: Ordering
    ) -> Result<Self::Underlying, Self::Underlying>; fn compare_exchange_weak(
        &self,
        current: Self::Underlying,
        new: Self::Underlying,
        success: Ordering,
        failure: Ordering
    ) -> Result<Self::Underlying, Self::Underlying>; fn forgettable() -> Self { ... } }
Expand description

An atomic type which can be safely shared between threads. Drop::drop behavior is somewhat unintuitive, so types are advised to avoid implementing it. See crate::cell::AtomicCell for more info.

Required Associated Constants

An underlying value initialized to zero. (i.e. all values of ZERO should be PartialEq and equal according to AtomicStorage::compare_exchange_weak).

Required Methods

Creates a new AtomicStorage with the value v.

Consumes the atomic and returns the contained value.

This is safe because passing self by value guarantees that no other threads are concurrently accessing the atomic data.

Returns a mutable reference to the underlying AtomicStorageBase::Underlying.

This is safe because the mutable reference guarantees that no other threads are concurrently accessing the atomic data.

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.

Stores a value into the atomic.

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.

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

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

Stores a value into the atomic 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.

compare_exchange takes two Ordering arguments to describe the memory ordering of this operation. success describes the required ordering for the read-modify-write operation that takes place if the comparison with current succeeds. failure describes the required ordering for the load operation that takes place when the comparison fails. Using Acquire as success ordering makes the store part of this operation Relaxed, and using Release makes the successful load Relaxed. The failure ordering can only be SeqCst, Acquire or Relaxed and must be equivalent to or weaker than the success ordering.

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

Unlike AtomicStorage::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.

compare_exchange_weak takes two Ordering arguments to describe the memory ordering of this operation. success describes the required ordering for the read-modify-write operation that takes place if the comparison with current succeeds. failure describes the required ordering for the load operation that takes place when the comparison fails. Using Acquire as success ordering makes the store part of this operation Relaxed, and using Release makes the successful load Relaxed. The failure ordering can only be SeqCst, Acquire or Relaxed and must be equivalent to or weaker than the success ordering.

Provided Methods

Creates an atomic value which can be safely forgotten

Implementors