Struct re_viewer::external::crossbeam::atomic::AtomicCell

#[repr(transparent)]
pub struct AtomicCell<T> { value: UnsafeCell<MaybeUninit<T>>, }
Expand description

A thread-safe mutable memory location.

This type is equivalent to Cell, except it can also be shared among multiple threads.

Operations on AtomicCells use atomic instructions whenever possible, and synchronize using global locks otherwise. You can call AtomicCell::<T>::is_lock_free() to check whether atomic instructions or locks will be used.

Atomic loads use the Acquire ordering and atomic stores use the Release ordering.

Fields§

§value: UnsafeCell<MaybeUninit<T>>

Implementations§

§

impl<T> AtomicCell<T>

pub const fn new(val: T) -> AtomicCell<T>

Creates a new atomic cell initialized with val.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7);

pub fn into_inner(self) -> T

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.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7);
let v = a.into_inner();

assert_eq!(v, 7);

pub const fn is_lock_free() -> bool

Returns true if operations on values of this type are lock-free.

If the compiler or the platform doesn’t support the necessary atomic instructions, AtomicCell<T> will use global locks for every potentially concurrent atomic operation.

§Examples
use crossbeam_utils::atomic::AtomicCell;

// This type is internally represented as `AtomicUsize` so we can just use atomic
// operations provided by it.
assert_eq!(AtomicCell::<usize>::is_lock_free(), true);

// A wrapper struct around `isize`.
struct Foo {
    bar: isize,
}
// `AtomicCell<Foo>` will be internally represented as `AtomicIsize`.
assert_eq!(AtomicCell::<Foo>::is_lock_free(), true);

// Operations on zero-sized types are always lock-free.
assert_eq!(AtomicCell::<()>::is_lock_free(), true);

// Very large types cannot be represented as any of the standard atomic types, so atomic
// operations on them will have to use global locks for synchronization.
assert_eq!(AtomicCell::<[u8; 1000]>::is_lock_free(), false);

pub fn store(&self, val: T)

Stores val into the atomic cell.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7);

assert_eq!(a.load(), 7);
a.store(8);
assert_eq!(a.load(), 8);

pub fn swap(&self, val: T) -> T

Stores val into the atomic cell and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7);

assert_eq!(a.load(), 7);
assert_eq!(a.swap(8), 7);
assert_eq!(a.load(), 8);

pub fn as_ptr(&self) -> *mut T

Returns a raw pointer to the underlying data in this atomic cell.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(5);

let ptr = a.as_ptr();
§

impl<T> AtomicCell<T>
where T: Default,

pub fn take(&self) -> T

Takes the value of the atomic cell, leaving Default::default() in its place.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(5);
let five = a.take();

assert_eq!(five, 5);
assert_eq!(a.into_inner(), 0);
§

impl<T> AtomicCell<T>
where T: Copy,

pub fn load(&self) -> T

Loads a value from the atomic cell.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7);

assert_eq!(a.load(), 7);
§

impl<T> AtomicCell<T>
where T: Copy + Eq,

pub fn compare_and_swap(&self, current: T, new: T) -> T

👎Deprecated: Use compare_exchange instead

If the current value equals current, stores new into the atomic cell.

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

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(1);

assert_eq!(a.compare_and_swap(2, 3), 1);
assert_eq!(a.load(), 1);

assert_eq!(a.compare_and_swap(1, 2), 1);
assert_eq!(a.load(), 2);

pub fn compare_exchange(&self, current: T, new: T) -> Result<T, T>

If the current value equals current, stores new into the atomic cell.

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.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(1);

assert_eq!(a.compare_exchange(2, 3), Err(1));
assert_eq!(a.load(), 1);

assert_eq!(a.compare_exchange(1, 2), Ok(1));
assert_eq!(a.load(), 2);

pub fn fetch_update<F>(&self, f: F) -> Result<T, T>
where F: FnMut(T) -> Option<T>,

Fetches the value, and applies a function to it that returns an optional new value. Returns a Result of Ok(previous_value) if the function returned Some(_), else Err(previous_value).

Note: This may call the function multiple times if the value has been changed from other threads in the meantime, as long as the function returns Some(_), but the function will have been applied only once to the stored value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7);
assert_eq!(a.fetch_update(|_| None), Err(7));
assert_eq!(a.fetch_update(|a| Some(a + 1)), Ok(7));
assert_eq!(a.fetch_update(|a| Some(a + 1)), Ok(8));
assert_eq!(a.load(), 9);
§

impl AtomicCell<u8>

pub fn fetch_add(&self, val: u8) -> u8

Increments the current value by val and returns the previous value.

The addition wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u8);

assert_eq!(a.fetch_add(3), 7);
assert_eq!(a.load(), 10);

pub fn fetch_sub(&self, val: u8) -> u8

Decrements the current value by val and returns the previous value.

The subtraction wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u8);

assert_eq!(a.fetch_sub(3), 7);
assert_eq!(a.load(), 4);

pub fn fetch_and(&self, val: u8) -> u8

Applies bitwise “and” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u8);

assert_eq!(a.fetch_and(3), 7);
assert_eq!(a.load(), 3);

pub fn fetch_nand(&self, val: u8) -> u8

Applies bitwise “nand” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u8);

assert_eq!(a.fetch_nand(3), 7);
assert_eq!(a.load(), !(7 & 3));

pub fn fetch_or(&self, val: u8) -> u8

Applies bitwise “or” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u8);

assert_eq!(a.fetch_or(16), 7);
assert_eq!(a.load(), 23);

pub fn fetch_xor(&self, val: u8) -> u8

Applies bitwise “xor” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u8);

assert_eq!(a.fetch_xor(2), 7);
assert_eq!(a.load(), 5);

pub fn fetch_max(&self, val: u8) -> u8

Compares and sets the maximum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u8);

assert_eq!(a.fetch_max(9), 7);
assert_eq!(a.load(), 9);

pub fn fetch_min(&self, val: u8) -> u8

Compares and sets the minimum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u8);

assert_eq!(a.fetch_min(2), 7);
assert_eq!(a.load(), 2);
§

impl AtomicCell<i8>

pub fn fetch_add(&self, val: i8) -> i8

Increments the current value by val and returns the previous value.

The addition wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i8);

assert_eq!(a.fetch_add(3), 7);
assert_eq!(a.load(), 10);

pub fn fetch_sub(&self, val: i8) -> i8

Decrements the current value by val and returns the previous value.

The subtraction wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i8);

assert_eq!(a.fetch_sub(3), 7);
assert_eq!(a.load(), 4);

pub fn fetch_and(&self, val: i8) -> i8

Applies bitwise “and” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i8);

assert_eq!(a.fetch_and(3), 7);
assert_eq!(a.load(), 3);

pub fn fetch_nand(&self, val: i8) -> i8

Applies bitwise “nand” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i8);

assert_eq!(a.fetch_nand(3), 7);
assert_eq!(a.load(), !(7 & 3));

pub fn fetch_or(&self, val: i8) -> i8

Applies bitwise “or” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i8);

assert_eq!(a.fetch_or(16), 7);
assert_eq!(a.load(), 23);

pub fn fetch_xor(&self, val: i8) -> i8

Applies bitwise “xor” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i8);

assert_eq!(a.fetch_xor(2), 7);
assert_eq!(a.load(), 5);

pub fn fetch_max(&self, val: i8) -> i8

Compares and sets the maximum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i8);

assert_eq!(a.fetch_max(9), 7);
assert_eq!(a.load(), 9);

pub fn fetch_min(&self, val: i8) -> i8

Compares and sets the minimum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i8);

assert_eq!(a.fetch_min(2), 7);
assert_eq!(a.load(), 2);
§

impl AtomicCell<u16>

pub fn fetch_add(&self, val: u16) -> u16

Increments the current value by val and returns the previous value.

The addition wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u16);

assert_eq!(a.fetch_add(3), 7);
assert_eq!(a.load(), 10);

pub fn fetch_sub(&self, val: u16) -> u16

Decrements the current value by val and returns the previous value.

The subtraction wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u16);

assert_eq!(a.fetch_sub(3), 7);
assert_eq!(a.load(), 4);

pub fn fetch_and(&self, val: u16) -> u16

Applies bitwise “and” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u16);

assert_eq!(a.fetch_and(3), 7);
assert_eq!(a.load(), 3);

pub fn fetch_nand(&self, val: u16) -> u16

Applies bitwise “nand” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u16);

assert_eq!(a.fetch_nand(3), 7);
assert_eq!(a.load(), !(7 & 3));

pub fn fetch_or(&self, val: u16) -> u16

Applies bitwise “or” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u16);

assert_eq!(a.fetch_or(16), 7);
assert_eq!(a.load(), 23);

pub fn fetch_xor(&self, val: u16) -> u16

Applies bitwise “xor” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u16);

assert_eq!(a.fetch_xor(2), 7);
assert_eq!(a.load(), 5);

pub fn fetch_max(&self, val: u16) -> u16

Compares and sets the maximum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u16);

assert_eq!(a.fetch_max(9), 7);
assert_eq!(a.load(), 9);

pub fn fetch_min(&self, val: u16) -> u16

Compares and sets the minimum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u16);

assert_eq!(a.fetch_min(2), 7);
assert_eq!(a.load(), 2);
§

impl AtomicCell<i16>

pub fn fetch_add(&self, val: i16) -> i16

Increments the current value by val and returns the previous value.

The addition wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i16);

assert_eq!(a.fetch_add(3), 7);
assert_eq!(a.load(), 10);

pub fn fetch_sub(&self, val: i16) -> i16

Decrements the current value by val and returns the previous value.

The subtraction wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i16);

assert_eq!(a.fetch_sub(3), 7);
assert_eq!(a.load(), 4);

pub fn fetch_and(&self, val: i16) -> i16

Applies bitwise “and” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i16);

assert_eq!(a.fetch_and(3), 7);
assert_eq!(a.load(), 3);

pub fn fetch_nand(&self, val: i16) -> i16

Applies bitwise “nand” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i16);

assert_eq!(a.fetch_nand(3), 7);
assert_eq!(a.load(), !(7 & 3));

pub fn fetch_or(&self, val: i16) -> i16

Applies bitwise “or” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i16);

assert_eq!(a.fetch_or(16), 7);
assert_eq!(a.load(), 23);

pub fn fetch_xor(&self, val: i16) -> i16

Applies bitwise “xor” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i16);

assert_eq!(a.fetch_xor(2), 7);
assert_eq!(a.load(), 5);

pub fn fetch_max(&self, val: i16) -> i16

Compares and sets the maximum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i16);

assert_eq!(a.fetch_max(9), 7);
assert_eq!(a.load(), 9);

pub fn fetch_min(&self, val: i16) -> i16

Compares and sets the minimum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i16);

assert_eq!(a.fetch_min(2), 7);
assert_eq!(a.load(), 2);
§

impl AtomicCell<u32>

pub fn fetch_add(&self, val: u32) -> u32

Increments the current value by val and returns the previous value.

The addition wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u32);

assert_eq!(a.fetch_add(3), 7);
assert_eq!(a.load(), 10);

pub fn fetch_sub(&self, val: u32) -> u32

Decrements the current value by val and returns the previous value.

The subtraction wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u32);

assert_eq!(a.fetch_sub(3), 7);
assert_eq!(a.load(), 4);

pub fn fetch_and(&self, val: u32) -> u32

Applies bitwise “and” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u32);

assert_eq!(a.fetch_and(3), 7);
assert_eq!(a.load(), 3);

pub fn fetch_nand(&self, val: u32) -> u32

Applies bitwise “nand” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u32);

assert_eq!(a.fetch_nand(3), 7);
assert_eq!(a.load(), !(7 & 3));

pub fn fetch_or(&self, val: u32) -> u32

Applies bitwise “or” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u32);

assert_eq!(a.fetch_or(16), 7);
assert_eq!(a.load(), 23);

pub fn fetch_xor(&self, val: u32) -> u32

Applies bitwise “xor” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u32);

assert_eq!(a.fetch_xor(2), 7);
assert_eq!(a.load(), 5);

pub fn fetch_max(&self, val: u32) -> u32

Compares and sets the maximum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u32);

assert_eq!(a.fetch_max(9), 7);
assert_eq!(a.load(), 9);

pub fn fetch_min(&self, val: u32) -> u32

Compares and sets the minimum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u32);

assert_eq!(a.fetch_min(2), 7);
assert_eq!(a.load(), 2);
§

impl AtomicCell<i32>

pub fn fetch_add(&self, val: i32) -> i32

Increments the current value by val and returns the previous value.

The addition wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i32);

assert_eq!(a.fetch_add(3), 7);
assert_eq!(a.load(), 10);

pub fn fetch_sub(&self, val: i32) -> i32

Decrements the current value by val and returns the previous value.

The subtraction wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i32);

assert_eq!(a.fetch_sub(3), 7);
assert_eq!(a.load(), 4);

pub fn fetch_and(&self, val: i32) -> i32

Applies bitwise “and” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i32);

assert_eq!(a.fetch_and(3), 7);
assert_eq!(a.load(), 3);

pub fn fetch_nand(&self, val: i32) -> i32

Applies bitwise “nand” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i32);

assert_eq!(a.fetch_nand(3), 7);
assert_eq!(a.load(), !(7 & 3));

pub fn fetch_or(&self, val: i32) -> i32

Applies bitwise “or” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i32);

assert_eq!(a.fetch_or(16), 7);
assert_eq!(a.load(), 23);

pub fn fetch_xor(&self, val: i32) -> i32

Applies bitwise “xor” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i32);

assert_eq!(a.fetch_xor(2), 7);
assert_eq!(a.load(), 5);

pub fn fetch_max(&self, val: i32) -> i32

Compares and sets the maximum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i32);

assert_eq!(a.fetch_max(9), 7);
assert_eq!(a.load(), 9);

pub fn fetch_min(&self, val: i32) -> i32

Compares and sets the minimum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i32);

assert_eq!(a.fetch_min(2), 7);
assert_eq!(a.load(), 2);
§

impl AtomicCell<u64>

pub fn fetch_add(&self, val: u64) -> u64

Increments the current value by val and returns the previous value.

The addition wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u64);

assert_eq!(a.fetch_add(3), 7);
assert_eq!(a.load(), 10);

pub fn fetch_sub(&self, val: u64) -> u64

Decrements the current value by val and returns the previous value.

The subtraction wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u64);

assert_eq!(a.fetch_sub(3), 7);
assert_eq!(a.load(), 4);

pub fn fetch_and(&self, val: u64) -> u64

Applies bitwise “and” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u64);

assert_eq!(a.fetch_and(3), 7);
assert_eq!(a.load(), 3);

pub fn fetch_nand(&self, val: u64) -> u64

Applies bitwise “nand” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u64);

assert_eq!(a.fetch_nand(3), 7);
assert_eq!(a.load(), !(7 & 3));

pub fn fetch_or(&self, val: u64) -> u64

Applies bitwise “or” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u64);

assert_eq!(a.fetch_or(16), 7);
assert_eq!(a.load(), 23);

pub fn fetch_xor(&self, val: u64) -> u64

Applies bitwise “xor” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u64);

assert_eq!(a.fetch_xor(2), 7);
assert_eq!(a.load(), 5);

pub fn fetch_max(&self, val: u64) -> u64

Compares and sets the maximum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u64);

assert_eq!(a.fetch_max(9), 7);
assert_eq!(a.load(), 9);

pub fn fetch_min(&self, val: u64) -> u64

Compares and sets the minimum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u64);

assert_eq!(a.fetch_min(2), 7);
assert_eq!(a.load(), 2);
§

impl AtomicCell<i64>

pub fn fetch_add(&self, val: i64) -> i64

Increments the current value by val and returns the previous value.

The addition wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i64);

assert_eq!(a.fetch_add(3), 7);
assert_eq!(a.load(), 10);

pub fn fetch_sub(&self, val: i64) -> i64

Decrements the current value by val and returns the previous value.

The subtraction wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i64);

assert_eq!(a.fetch_sub(3), 7);
assert_eq!(a.load(), 4);

pub fn fetch_and(&self, val: i64) -> i64

Applies bitwise “and” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i64);

assert_eq!(a.fetch_and(3), 7);
assert_eq!(a.load(), 3);

pub fn fetch_nand(&self, val: i64) -> i64

Applies bitwise “nand” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i64);

assert_eq!(a.fetch_nand(3), 7);
assert_eq!(a.load(), !(7 & 3));

pub fn fetch_or(&self, val: i64) -> i64

Applies bitwise “or” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i64);

assert_eq!(a.fetch_or(16), 7);
assert_eq!(a.load(), 23);

pub fn fetch_xor(&self, val: i64) -> i64

Applies bitwise “xor” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i64);

assert_eq!(a.fetch_xor(2), 7);
assert_eq!(a.load(), 5);

pub fn fetch_max(&self, val: i64) -> i64

Compares and sets the maximum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i64);

assert_eq!(a.fetch_max(9), 7);
assert_eq!(a.load(), 9);

pub fn fetch_min(&self, val: i64) -> i64

Compares and sets the minimum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i64);

assert_eq!(a.fetch_min(2), 7);
assert_eq!(a.load(), 2);
§

impl AtomicCell<u128>

pub fn fetch_add(&self, val: u128) -> u128

Increments the current value by val and returns the previous value.

The addition wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u128);

assert_eq!(a.fetch_add(3), 7);
assert_eq!(a.load(), 10);

pub fn fetch_sub(&self, val: u128) -> u128

Decrements the current value by val and returns the previous value.

The subtraction wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u128);

assert_eq!(a.fetch_sub(3), 7);
assert_eq!(a.load(), 4);

pub fn fetch_and(&self, val: u128) -> u128

Applies bitwise “and” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u128);

assert_eq!(a.fetch_and(3), 7);
assert_eq!(a.load(), 3);

pub fn fetch_nand(&self, val: u128) -> u128

Applies bitwise “nand” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u128);

assert_eq!(a.fetch_nand(3), 7);
assert_eq!(a.load(), !(7 & 3));

pub fn fetch_or(&self, val: u128) -> u128

Applies bitwise “or” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u128);

assert_eq!(a.fetch_or(16), 7);
assert_eq!(a.load(), 23);

pub fn fetch_xor(&self, val: u128) -> u128

Applies bitwise “xor” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u128);

assert_eq!(a.fetch_xor(2), 7);
assert_eq!(a.load(), 5);

pub fn fetch_max(&self, val: u128) -> u128

Compares and sets the maximum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u128);

assert_eq!(a.fetch_max(2), 7);
assert_eq!(a.load(), 7);

pub fn fetch_min(&self, val: u128) -> u128

Compares and sets the minimum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7u128);

assert_eq!(a.fetch_min(2), 7);
assert_eq!(a.load(), 2);
§

impl AtomicCell<i128>

pub fn fetch_add(&self, val: i128) -> i128

Increments the current value by val and returns the previous value.

The addition wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i128);

assert_eq!(a.fetch_add(3), 7);
assert_eq!(a.load(), 10);

pub fn fetch_sub(&self, val: i128) -> i128

Decrements the current value by val and returns the previous value.

The subtraction wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i128);

assert_eq!(a.fetch_sub(3), 7);
assert_eq!(a.load(), 4);

pub fn fetch_and(&self, val: i128) -> i128

Applies bitwise “and” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i128);

assert_eq!(a.fetch_and(3), 7);
assert_eq!(a.load(), 3);

pub fn fetch_nand(&self, val: i128) -> i128

Applies bitwise “nand” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i128);

assert_eq!(a.fetch_nand(3), 7);
assert_eq!(a.load(), !(7 & 3));

pub fn fetch_or(&self, val: i128) -> i128

Applies bitwise “or” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i128);

assert_eq!(a.fetch_or(16), 7);
assert_eq!(a.load(), 23);

pub fn fetch_xor(&self, val: i128) -> i128

Applies bitwise “xor” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i128);

assert_eq!(a.fetch_xor(2), 7);
assert_eq!(a.load(), 5);

pub fn fetch_max(&self, val: i128) -> i128

Compares and sets the maximum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i128);

assert_eq!(a.fetch_max(2), 7);
assert_eq!(a.load(), 7);

pub fn fetch_min(&self, val: i128) -> i128

Compares and sets the minimum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7i128);

assert_eq!(a.fetch_min(2), 7);
assert_eq!(a.load(), 2);
§

impl AtomicCell<usize>

pub fn fetch_add(&self, val: usize) -> usize

Increments the current value by val and returns the previous value.

The addition wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7usize);

assert_eq!(a.fetch_add(3), 7);
assert_eq!(a.load(), 10);

pub fn fetch_sub(&self, val: usize) -> usize

Decrements the current value by val and returns the previous value.

The subtraction wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7usize);

assert_eq!(a.fetch_sub(3), 7);
assert_eq!(a.load(), 4);

pub fn fetch_and(&self, val: usize) -> usize

Applies bitwise “and” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7usize);

assert_eq!(a.fetch_and(3), 7);
assert_eq!(a.load(), 3);

pub fn fetch_nand(&self, val: usize) -> usize

Applies bitwise “nand” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7usize);

assert_eq!(a.fetch_nand(3), 7);
assert_eq!(a.load(), !(7 & 3));

pub fn fetch_or(&self, val: usize) -> usize

Applies bitwise “or” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7usize);

assert_eq!(a.fetch_or(16), 7);
assert_eq!(a.load(), 23);

pub fn fetch_xor(&self, val: usize) -> usize

Applies bitwise “xor” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7usize);

assert_eq!(a.fetch_xor(2), 7);
assert_eq!(a.load(), 5);

pub fn fetch_max(&self, val: usize) -> usize

Compares and sets the maximum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7usize);

assert_eq!(a.fetch_max(9), 7);
assert_eq!(a.load(), 9);

pub fn fetch_min(&self, val: usize) -> usize

Compares and sets the minimum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7usize);

assert_eq!(a.fetch_min(2), 7);
assert_eq!(a.load(), 2);
§

impl AtomicCell<isize>

pub fn fetch_add(&self, val: isize) -> isize

Increments the current value by val and returns the previous value.

The addition wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7isize);

assert_eq!(a.fetch_add(3), 7);
assert_eq!(a.load(), 10);

pub fn fetch_sub(&self, val: isize) -> isize

Decrements the current value by val and returns the previous value.

The subtraction wraps on overflow.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7isize);

assert_eq!(a.fetch_sub(3), 7);
assert_eq!(a.load(), 4);

pub fn fetch_and(&self, val: isize) -> isize

Applies bitwise “and” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7isize);

assert_eq!(a.fetch_and(3), 7);
assert_eq!(a.load(), 3);

pub fn fetch_nand(&self, val: isize) -> isize

Applies bitwise “nand” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7isize);

assert_eq!(a.fetch_nand(3), 7);
assert_eq!(a.load(), !(7 & 3));

pub fn fetch_or(&self, val: isize) -> isize

Applies bitwise “or” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7isize);

assert_eq!(a.fetch_or(16), 7);
assert_eq!(a.load(), 23);

pub fn fetch_xor(&self, val: isize) -> isize

Applies bitwise “xor” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7isize);

assert_eq!(a.fetch_xor(2), 7);
assert_eq!(a.load(), 5);

pub fn fetch_max(&self, val: isize) -> isize

Compares and sets the maximum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7isize);

assert_eq!(a.fetch_max(9), 7);
assert_eq!(a.load(), 9);

pub fn fetch_min(&self, val: isize) -> isize

Compares and sets the minimum of the current value and val, and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(7isize);

assert_eq!(a.fetch_min(2), 7);
assert_eq!(a.load(), 2);
§

impl AtomicCell<bool>

pub fn fetch_and(&self, val: bool) -> bool

Applies logical “and” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(true);

assert_eq!(a.fetch_and(true), true);
assert_eq!(a.load(), true);

assert_eq!(a.fetch_and(false), true);
assert_eq!(a.load(), false);

pub fn fetch_nand(&self, val: bool) -> bool

Applies logical “nand” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(true);

assert_eq!(a.fetch_nand(false), true);
assert_eq!(a.load(), true);

assert_eq!(a.fetch_nand(true), true);
assert_eq!(a.load(), false);

assert_eq!(a.fetch_nand(false), false);
assert_eq!(a.load(), true);

pub fn fetch_or(&self, val: bool) -> bool

Applies logical “or” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(false);

assert_eq!(a.fetch_or(false), false);
assert_eq!(a.load(), false);

assert_eq!(a.fetch_or(true), false);
assert_eq!(a.load(), true);

pub fn fetch_xor(&self, val: bool) -> bool

Applies logical “xor” to the current value and returns the previous value.

§Examples
use crossbeam_utils::atomic::AtomicCell;

let a = AtomicCell::new(true);

assert_eq!(a.fetch_xor(false), true);
assert_eq!(a.load(), true);

assert_eq!(a.fetch_xor(true), true);
assert_eq!(a.load(), false);

Trait Implementations§

§

impl<T> Debug for AtomicCell<T>
where T: Copy + Debug,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T> Default for AtomicCell<T>
where T: Default,

§

fn default() -> AtomicCell<T>

Returns the “default value” for a type. Read more
§

impl<T> Drop for AtomicCell<T>

§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

impl<T> From<T> for AtomicCell<T>

§

fn from(val: T) -> AtomicCell<T>

Converts to this type from the input type.
§

impl<T> RefUnwindSafe for AtomicCell<T>

§

impl<T> Send for AtomicCell<T>
where T: Send,

§

impl<T> Sync for AtomicCell<T>
where T: Send,

§

impl<T> UnwindSafe for AtomicCell<T>

Auto Trait Implementations§

§

impl<T> !Freeze for AtomicCell<T>

§

impl<T> Unpin for AtomicCell<T>
where T: Unpin,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

source§

fn lossy_into(self) -> Dst

Performs the conversion.
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T> To for T
where T: ?Sized,

§

fn to<T>(self) -> T
where Self: Into<T>,

Converts to T by calling Into<T>::into.
§

fn try_to<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

§

impl<T> Ungil for T
where T: Send,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,