Struct heron::rapier_plugin::rapier2d::crossbeam::atomic::AtomicCell [−]
#[repr(transparent)]pub struct AtomicCell<T> where
T: ?Sized, { /* fields omitted */ }
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 AtomicCell
s 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.
Implementations
impl<T> AtomicCell<T>
impl<T> AtomicCell<T>
pub const fn new(val: 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
pub fn into_inner(self) -> T
Consumes the atomic and returns the contained value.
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
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);
impl<T> AtomicCell<T> where
T: ?Sized,
impl<T> AtomicCell<T> where
T: ?Sized,
impl<T> AtomicCell<T> where
T: Default,
impl<T> AtomicCell<T> where
T: Default,
impl<T> AtomicCell<T> where
T: Copy,
impl<T> AtomicCell<T> where
T: Copy,
impl<T> AtomicCell<T> where
T: Copy + Eq,
impl<T> AtomicCell<T> where
T: Copy + Eq,
pub fn compare_and_swap(&self, current: T, new: T) -> T
👎 Deprecated: Use compare_exchange
instead
pub fn compare_and_swap(&self, current: T, new: T) -> T
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>
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>,
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<bool>
impl AtomicCell<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);
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);
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);
impl AtomicCell<u8>
impl AtomicCell<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);
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);
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);
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);
impl AtomicCell<i8>
impl AtomicCell<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);
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);
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);
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);
impl AtomicCell<u16>
impl AtomicCell<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);
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);
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);
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);
impl AtomicCell<i16>
impl AtomicCell<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);
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);
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);
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);
impl AtomicCell<u32>
impl AtomicCell<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);
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);
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);
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);
impl AtomicCell<i32>
impl AtomicCell<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);
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);
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);
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);
impl AtomicCell<u64>
impl AtomicCell<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);
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);
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);
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);
impl AtomicCell<i64>
impl AtomicCell<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);
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);
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);
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);
impl AtomicCell<usize>
impl AtomicCell<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);
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);
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);
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);
impl AtomicCell<isize>
impl AtomicCell<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);
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);
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);
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);
Trait Implementations
impl<T> Debug for AtomicCell<T> where
T: Copy + Debug,
impl<T> Debug for AtomicCell<T> where
T: Copy + Debug,
impl<T> Default for AtomicCell<T> where
T: Default,
impl<T> Default for AtomicCell<T> where
T: Default,
pub fn default() -> AtomicCell<T>
pub fn default() -> AtomicCell<T>
Returns the “default value” for a type. Read more
impl<T> From<T> for AtomicCell<T>
impl<T> From<T> for AtomicCell<T>
pub fn from(val: T) -> AtomicCell<T>
pub fn from(val: T) -> AtomicCell<T>
Performs the conversion.
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: ?Sized> Unpin for AtomicCell<T> where
T: Unpin,
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: 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
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub 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. Read more
impl<T> FromWorld for T where
T: Default,
impl<T> FromWorld for T where
T: Default,
pub fn from_world(_world: &mut World) -> T
pub fn from_world(_world: &mut World) -> T
Creates Self
using data from the given [World]
impl<T> Pointable for T
impl<T> Pointable for T
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more