[][src]Struct atomic::Atomic

pub struct Atomic<T: Copy> { /* fields omitted */ }

A generic atomic wrapper type which allows an object to be safely shared between threads.

Implementations

impl<T: Copy> Atomic<T>[src]

pub const fn new(v: T) -> Atomic<T>[src]

Creates a new Atomic.

pub const fn is_lock_free() -> bool[src]

Checks if Atomic objects of this type are lock-free.

If an Atomic is not lock-free then it may be implemented using locks internally, which makes it unsuitable for some situations (such as communicating with a signal handler).

pub fn get_mut(&mut self) -> &mut T[src]

Returns a mutable reference to the underlying type.

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

pub fn into_inner(self) -> T[src]

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.

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

Loads a value from the Atomic.

load takes an Ordering argument which describes the memory ordering of this operation.

Panics

Panics if order is Release or AcqRel.

pub fn store(&self, val: T, order: Ordering)[src]

Stores a value into the Atomic.

store takes an Ordering argument which describes the memory ordering of this operation.

Panics

Panics if order is Acquire or AcqRel.

pub fn swap(&self, val: T, order: Ordering) -> T[src]

Stores a value into the Atomic, returning the old value.

swap takes an Ordering argument which describes the memory ordering of this operation.

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

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 new.

compare_exchange takes two Ordering arguments to describe the memory ordering of this operation. The first describes the required ordering if the operation succeeds while the second describes the required ordering when the operation fails. The failure ordering can't be Acquire or AcqRel and must be equivalent or weaker than the success ordering.

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

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

compare_exchange takes two Ordering arguments to describe the memory ordering of this operation. The first describes the required ordering if the operation succeeds while the second describes the required ordering when the operation fails. The failure ordering can't be Acquire or AcqRel and must be equivalent or weaker than the success ordering. success ordering.

impl Atomic<bool>[src]

pub fn fetch_and(&self, val: bool, order: Ordering) -> bool[src]

Logical "and" with a boolean value.

Performs a logical "and" operation on the current value and the argument val, and sets the new value to the result.

Returns the previous value.

pub fn fetch_or(&self, val: bool, order: Ordering) -> bool[src]

Logical "or" with a boolean value.

Performs a logical "or" operation on the current value and the argument val, and sets the new value to the result.

Returns the previous value.

pub fn fetch_xor(&self, val: bool, order: Ordering) -> bool[src]

Logical "xor" with a boolean value.

Performs a logical "xor" operation on the current value and the argument val, and sets the new value to the result.

Returns the previous value.

impl Atomic<i8>[src]

pub fn fetch_add(&self, val: i8, order: Ordering) -> i8[src]

Add to the current value, returning the previous value.

pub fn fetch_sub(&self, val: i8, order: Ordering) -> i8[src]

Subtract from the current value, returning the previous value.

pub fn fetch_and(&self, val: i8, order: Ordering) -> i8[src]

Bitwise and with the current value, returning the previous value.

pub fn fetch_or(&self, val: i8, order: Ordering) -> i8[src]

Bitwise or with the current value, returning the previous value.

pub fn fetch_xor(&self, val: i8, order: Ordering) -> i8[src]

Bitwise xor with the current value, returning the previous value.

impl Atomic<i16>[src]

pub fn fetch_add(&self, val: i16, order: Ordering) -> i16[src]

Add to the current value, returning the previous value.

pub fn fetch_sub(&self, val: i16, order: Ordering) -> i16[src]

Subtract from the current value, returning the previous value.

pub fn fetch_and(&self, val: i16, order: Ordering) -> i16[src]

Bitwise and with the current value, returning the previous value.

pub fn fetch_or(&self, val: i16, order: Ordering) -> i16[src]

Bitwise or with the current value, returning the previous value.

pub fn fetch_xor(&self, val: i16, order: Ordering) -> i16[src]

Bitwise xor with the current value, returning the previous value.

impl Atomic<i32>[src]

pub fn fetch_add(&self, val: i32, order: Ordering) -> i32[src]

Add to the current value, returning the previous value.

pub fn fetch_sub(&self, val: i32, order: Ordering) -> i32[src]

Subtract from the current value, returning the previous value.

pub fn fetch_and(&self, val: i32, order: Ordering) -> i32[src]

Bitwise and with the current value, returning the previous value.

pub fn fetch_or(&self, val: i32, order: Ordering) -> i32[src]

Bitwise or with the current value, returning the previous value.

pub fn fetch_xor(&self, val: i32, order: Ordering) -> i32[src]

Bitwise xor with the current value, returning the previous value.

impl Atomic<i64>[src]

pub fn fetch_add(&self, val: i64, order: Ordering) -> i64[src]

Add to the current value, returning the previous value.

pub fn fetch_sub(&self, val: i64, order: Ordering) -> i64[src]

Subtract from the current value, returning the previous value.

pub fn fetch_and(&self, val: i64, order: Ordering) -> i64[src]

Bitwise and with the current value, returning the previous value.

pub fn fetch_or(&self, val: i64, order: Ordering) -> i64[src]

Bitwise or with the current value, returning the previous value.

pub fn fetch_xor(&self, val: i64, order: Ordering) -> i64[src]

Bitwise xor with the current value, returning the previous value.

impl Atomic<isize>[src]

pub fn fetch_add(&self, val: isize, order: Ordering) -> isize[src]

Add to the current value, returning the previous value.

pub fn fetch_sub(&self, val: isize, order: Ordering) -> isize[src]

Subtract from the current value, returning the previous value.

pub fn fetch_and(&self, val: isize, order: Ordering) -> isize[src]

Bitwise and with the current value, returning the previous value.

pub fn fetch_or(&self, val: isize, order: Ordering) -> isize[src]

Bitwise or with the current value, returning the previous value.

pub fn fetch_xor(&self, val: isize, order: Ordering) -> isize[src]

Bitwise xor with the current value, returning the previous value.

impl Atomic<i128>[src]

pub fn fetch_add(&self, val: i128, order: Ordering) -> i128[src]

Add to the current value, returning the previous value.

pub fn fetch_sub(&self, val: i128, order: Ordering) -> i128[src]

Subtract from the current value, returning the previous value.

pub fn fetch_and(&self, val: i128, order: Ordering) -> i128[src]

Bitwise and with the current value, returning the previous value.

pub fn fetch_or(&self, val: i128, order: Ordering) -> i128[src]

Bitwise or with the current value, returning the previous value.

pub fn fetch_xor(&self, val: i128, order: Ordering) -> i128[src]

Bitwise xor with the current value, returning the previous value.

impl Atomic<i8>[src]

pub fn fetch_min(&self, val: i8, order: Ordering) -> i8[src]

Minimum with the current value.

pub fn fetch_max(&self, val: i8, order: Ordering) -> i8[src]

Maximum with the current value.

impl Atomic<i16>[src]

pub fn fetch_min(&self, val: i16, order: Ordering) -> i16[src]

Minimum with the current value.

pub fn fetch_max(&self, val: i16, order: Ordering) -> i16[src]

Maximum with the current value.

impl Atomic<i32>[src]

pub fn fetch_min(&self, val: i32, order: Ordering) -> i32[src]

Minimum with the current value.

pub fn fetch_max(&self, val: i32, order: Ordering) -> i32[src]

Maximum with the current value.

impl Atomic<i64>[src]

pub fn fetch_min(&self, val: i64, order: Ordering) -> i64[src]

Minimum with the current value.

pub fn fetch_max(&self, val: i64, order: Ordering) -> i64[src]

Maximum with the current value.

impl Atomic<isize>[src]

pub fn fetch_min(&self, val: isize, order: Ordering) -> isize[src]

Minimum with the current value.

pub fn fetch_max(&self, val: isize, order: Ordering) -> isize[src]

Maximum with the current value.

impl Atomic<i128>[src]

pub fn fetch_min(&self, val: i128, order: Ordering) -> i128[src]

Minimum with the current value.

pub fn fetch_max(&self, val: i128, order: Ordering) -> i128[src]

Maximum with the current value.

impl Atomic<u8>[src]

pub fn fetch_add(&self, val: u8, order: Ordering) -> u8[src]

Add to the current value, returning the previous value.

pub fn fetch_sub(&self, val: u8, order: Ordering) -> u8[src]

Subtract from the current value, returning the previous value.

pub fn fetch_and(&self, val: u8, order: Ordering) -> u8[src]

Bitwise and with the current value, returning the previous value.

pub fn fetch_or(&self, val: u8, order: Ordering) -> u8[src]

Bitwise or with the current value, returning the previous value.

pub fn fetch_xor(&self, val: u8, order: Ordering) -> u8[src]

Bitwise xor with the current value, returning the previous value.

impl Atomic<u16>[src]

pub fn fetch_add(&self, val: u16, order: Ordering) -> u16[src]

Add to the current value, returning the previous value.

pub fn fetch_sub(&self, val: u16, order: Ordering) -> u16[src]

Subtract from the current value, returning the previous value.

pub fn fetch_and(&self, val: u16, order: Ordering) -> u16[src]

Bitwise and with the current value, returning the previous value.

pub fn fetch_or(&self, val: u16, order: Ordering) -> u16[src]

Bitwise or with the current value, returning the previous value.

pub fn fetch_xor(&self, val: u16, order: Ordering) -> u16[src]

Bitwise xor with the current value, returning the previous value.

impl Atomic<u32>[src]

pub fn fetch_add(&self, val: u32, order: Ordering) -> u32[src]

Add to the current value, returning the previous value.

pub fn fetch_sub(&self, val: u32, order: Ordering) -> u32[src]

Subtract from the current value, returning the previous value.

pub fn fetch_and(&self, val: u32, order: Ordering) -> u32[src]

Bitwise and with the current value, returning the previous value.

pub fn fetch_or(&self, val: u32, order: Ordering) -> u32[src]

Bitwise or with the current value, returning the previous value.

pub fn fetch_xor(&self, val: u32, order: Ordering) -> u32[src]

Bitwise xor with the current value, returning the previous value.

impl Atomic<u64>[src]

pub fn fetch_add(&self, val: u64, order: Ordering) -> u64[src]

Add to the current value, returning the previous value.

pub fn fetch_sub(&self, val: u64, order: Ordering) -> u64[src]

Subtract from the current value, returning the previous value.

pub fn fetch_and(&self, val: u64, order: Ordering) -> u64[src]

Bitwise and with the current value, returning the previous value.

pub fn fetch_or(&self, val: u64, order: Ordering) -> u64[src]

Bitwise or with the current value, returning the previous value.

pub fn fetch_xor(&self, val: u64, order: Ordering) -> u64[src]

Bitwise xor with the current value, returning the previous value.

impl Atomic<usize>[src]

pub fn fetch_add(&self, val: usize, order: Ordering) -> usize[src]

Add to the current value, returning the previous value.

pub fn fetch_sub(&self, val: usize, order: Ordering) -> usize[src]

Subtract from the current value, returning the previous value.

pub fn fetch_and(&self, val: usize, order: Ordering) -> usize[src]

Bitwise and with the current value, returning the previous value.

pub fn fetch_or(&self, val: usize, order: Ordering) -> usize[src]

Bitwise or with the current value, returning the previous value.

pub fn fetch_xor(&self, val: usize, order: Ordering) -> usize[src]

Bitwise xor with the current value, returning the previous value.

impl Atomic<u128>[src]

pub fn fetch_add(&self, val: u128, order: Ordering) -> u128[src]

Add to the current value, returning the previous value.

pub fn fetch_sub(&self, val: u128, order: Ordering) -> u128[src]

Subtract from the current value, returning the previous value.

pub fn fetch_and(&self, val: u128, order: Ordering) -> u128[src]

Bitwise and with the current value, returning the previous value.

pub fn fetch_or(&self, val: u128, order: Ordering) -> u128[src]

Bitwise or with the current value, returning the previous value.

pub fn fetch_xor(&self, val: u128, order: Ordering) -> u128[src]

Bitwise xor with the current value, returning the previous value.

impl Atomic<u8>[src]

pub fn fetch_min(&self, val: u8, order: Ordering) -> u8[src]

Minimum with the current value.

pub fn fetch_max(&self, val: u8, order: Ordering) -> u8[src]

Maximum with the current value.

impl Atomic<u16>[src]

pub fn fetch_min(&self, val: u16, order: Ordering) -> u16[src]

Minimum with the current value.

pub fn fetch_max(&self, val: u16, order: Ordering) -> u16[src]

Maximum with the current value.

impl Atomic<u32>[src]

pub fn fetch_min(&self, val: u32, order: Ordering) -> u32[src]

Minimum with the current value.

pub fn fetch_max(&self, val: u32, order: Ordering) -> u32[src]

Maximum with the current value.

impl Atomic<u64>[src]

pub fn fetch_min(&self, val: u64, order: Ordering) -> u64[src]

Minimum with the current value.

pub fn fetch_max(&self, val: u64, order: Ordering) -> u64[src]

Maximum with the current value.

impl Atomic<usize>[src]

pub fn fetch_min(&self, val: usize, order: Ordering) -> usize[src]

Minimum with the current value.

pub fn fetch_max(&self, val: usize, order: Ordering) -> usize[src]

Maximum with the current value.

impl Atomic<u128>[src]

pub fn fetch_min(&self, val: u128, order: Ordering) -> u128[src]

Minimum with the current value.

pub fn fetch_max(&self, val: u128, order: Ordering) -> u128[src]

Maximum with the current value.

Trait Implementations

impl<T: Copy + Debug> Debug for Atomic<T>[src]

impl<T: Copy + Default> Default for Atomic<T>[src]

impl<T: Copy + Send> Sync for Atomic<T>[src]

Auto Trait Implementations

impl<T> Send for Atomic<T> where
    T: Send

impl<T> Unpin for Atomic<T> where
    T: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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.