pub struct Atomic<Inner: CubePrimitive> {
pub val: Inner,
}
Expand description
An atomic numerical type wrapping a normal numeric primitive. Enables the use of atomic operations, while disabling normal operations. In WGSL, this is a separate type - on CUDA/SPIR-V it can theoretically be bitcast to a normal number, but this isn’t recommended.
Fields§
§val: Inner
Implementations§
Source§impl<Inner: Numeric> Atomic<Inner>
impl<Inner: Numeric> Atomic<Inner>
Sourcepub fn swap(pointer: &Self, value: Inner) -> Inner
pub fn swap(pointer: &Self, value: Inner) -> Inner
Atomically stores the value into the atomic and returns the old value.
Sourcepub fn add(pointer: &Self, value: Inner) -> Inner
pub fn add(pointer: &Self, value: Inner) -> Inner
Atomically add a number to the atomic variable. Returns the old value.
Sourcepub fn max(pointer: &Self, value: Inner) -> Inner
pub fn max(pointer: &Self, value: Inner) -> Inner
Atomically sets the value of the atomic variable to max(current_value, value)
. Returns
the old value.
Sourcepub fn min(pointer: &Self, value: Inner) -> Inner
pub fn min(pointer: &Self, value: Inner) -> Inner
Atomically sets the value of the atomic variable to min(current_value, value)
. Returns the
old value.
Sourcepub fn sub(pointer: &Self, value: Inner) -> Inner
pub fn sub(pointer: &Self, value: Inner) -> Inner
Atomically subtracts a number from the atomic variable. Returns the old value.
pub fn __expand_load( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_store( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, )
pub fn __expand_swap( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_add( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_sub( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_max( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_min( scope: &mut Scope, pointer: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
Source§impl<Inner: Int> Atomic<Inner>
impl<Inner: Int> Atomic<Inner>
Sourcepub fn compare_and_swap(pointer: &Self, cmp: Inner, value: Inner) -> Inner
pub fn compare_and_swap(pointer: &Self, cmp: Inner, value: Inner) -> Inner
Compare the value at pointer
to cmp
and set it to value
only if they are the same.
Returns the old value of the pointer before the store.
§Tip
Compare the returned value to cmp
to determine whether the store was successful.
Sourcepub fn and(pointer: &Self, value: Inner) -> Inner
pub fn and(pointer: &Self, value: Inner) -> Inner
Executes an atomic bitwise and operation on the atomic variable. Returns the old value.
Sourcepub fn or(pointer: &Self, value: Inner) -> Inner
pub fn or(pointer: &Self, value: Inner) -> Inner
Executes an atomic bitwise or operation on the atomic variable. Returns the old value.
Sourcepub fn xor(pointer: &Self, value: Inner) -> Inner
pub fn xor(pointer: &Self, value: Inner) -> Inner
Executes an atomic bitwise xor operation on the atomic variable. Returns the old value.