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: InnerImplementations§
Source§impl<Inner: Numeric> Atomic<Inner>
impl<Inner: Numeric> Atomic<Inner>
Sourcepub fn swap(&self, value: Inner) -> Inner
pub fn swap(&self, value: Inner) -> Inner
Atomically stores the value into the atomic and returns the old value.
Sourcepub fn fetch_add(&self, value: Inner) -> Inner
pub fn fetch_add(&self, value: Inner) -> Inner
Atomically add a number to the atomic variable. Returns the old value.
Sourcepub fn fetch_sub(&self, value: Inner) -> Inner
pub fn fetch_sub(&self, value: Inner) -> Inner
Atomically subtracts a number from the atomic variable. Returns the old value.
Sourcepub fn fetch_max(&self, value: Inner) -> Inner
pub fn fetch_max(&self, value: Inner) -> Inner
Atomically sets the value of the atomic variable to max(current_value, value). Returns
the old value.
Sourcepub fn fetch_min(&self, value: Inner) -> Inner
pub fn fetch_min(&self, value: Inner) -> Inner
Atomically sets the value of the atomic variable to min(current_value, value). Returns the
old value.
pub fn __expand_load( scope: &mut Scope, this: <Self as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_store( scope: &mut Scope, this: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <() as CubeType>::ExpandType
pub fn __expand_swap( scope: &mut Scope, this: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_add( scope: &mut Scope, this: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_sub( scope: &mut Scope, this: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_max( scope: &mut Scope, this: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_min( scope: &mut Scope, this: <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_exchange_weak(&self, cmp: Inner, value: Inner) -> Inner
pub fn compare_exchange_weak(&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 fetch_and(&self, value: Inner) -> Inner
pub fn fetch_and(&self, value: Inner) -> Inner
Executes an atomic bitwise and operation on the atomic variable. Returns the old value.
Sourcepub fn fetch_or(&self, value: Inner) -> Inner
pub fn fetch_or(&self, value: Inner) -> Inner
Executes an atomic bitwise or operation on the atomic variable. Returns the old value.
Sourcepub fn fetch_xor(&self, value: Inner) -> Inner
pub fn fetch_xor(&self, value: Inner) -> Inner
Executes an atomic bitwise xor operation on the atomic variable. Returns the old value.
pub fn __expand_compare_exchange_weak( scope: &mut Scope, this: <Self as CubeType>::ExpandType, cmp: <Inner as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_and( scope: &mut Scope, this: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_or( scope: &mut Scope, this: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_xor( scope: &mut Scope, this: <Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
Trait Implementations§
Source§impl<Inner: CubePrimitive> CubePrimitive for Atomic<Inner>
impl<Inner: CubePrimitive> CubePrimitive for Atomic<Inner>
Source§fn as_type_native() -> Option<StorageType>
fn as_type_native() -> Option<StorageType>
Source§fn as_type(scope: &Scope) -> StorageType
fn as_type(scope: &Scope) -> StorageType
Source§fn as_type_native_unchecked() -> StorageType
fn as_type_native_unchecked() -> StorageType
fn from_expand_elem(elem: ExpandElement) -> Self::ExpandType
fn from_const_value(_value: ConstantValue) -> Self
Source§fn size_bits_unchecked() -> usize
fn size_bits_unchecked() -> usize
fn into_lit_unchecked(self) -> Self
fn supported_uses<R: Runtime>(client: &ComputeClient<R>) -> EnumSet<TypeUsage>
fn type_size() -> usize
fn type_size_bits() -> usize
fn packing_factor() -> usize
fn __expand_type_size(scope: &Scope) -> usize
fn __expand_type_size_bits(scope: &Scope) -> usize
fn __expand_packing_factor(scope: &Scope) -> usize
Source§impl<Inner: CubePrimitive> CubeType for Atomic<Inner>
impl<Inner: CubePrimitive> CubeType for Atomic<Inner>
type ExpandType = ExpandElementTyped<Atomic<Inner>>
Source§fn into_mut(scope: &mut Scope, expand: Self::ExpandType) -> Self::ExpandType
fn into_mut(scope: &mut Scope, expand: Self::ExpandType) -> Self::ExpandType
Source§impl<Inner: CubePrimitive> ExpandElementIntoMut for Atomic<Inner>
impl<Inner: CubePrimitive> ExpandElementIntoMut for Atomic<Inner>
fn elem_into_mut(scope: &mut Scope, elem: ExpandElement) -> ExpandElement
impl<Inner: Copy + CubePrimitive> Copy for Atomic<Inner>
impl<Inner: Eq + CubePrimitive> Eq for Atomic<Inner>
impl<Inner: CubePrimitive> StructuralPartialEq for Atomic<Inner>
Auto Trait Implementations§
impl<Inner> Freeze for Atomic<Inner>where
Inner: Freeze,
impl<Inner> RefUnwindSafe for Atomic<Inner>where
Inner: RefUnwindSafe,
impl<Inner> Send for Atomic<Inner>
impl<Inner> Sync for Atomic<Inner>
impl<Inner> Unpin for Atomic<Inner>where
Inner: Unpin,
impl<Inner> UnwindSafe for Atomic<Inner>where
Inner: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<P> Cast for Pwhere
P: CubePrimitive,
impl<P> Cast for Pwhere
P: CubePrimitive,
fn cast_from<From>(_value: From) -> Pwhere
From: CubePrimitive,
fn __expand_cast_from<From: CubePrimitive>( scope: &mut Scope, value: ExpandElementTyped<From>, ) -> <Self as CubeType>::ExpandType
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<P> CubeDebug for Pwhere
P: CubePrimitive,
impl<P> CubeDebug for Pwhere
P: CubePrimitive,
Source§fn set_debug_name(&self, scope: &mut Scope, name: &'static str)
fn set_debug_name(&self, scope: &mut Scope, name: &'static str)
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.