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: CubePrimitive<Scalar: AtomicNumeric>> Atomic<Inner>
impl<Inner: CubePrimitive<Scalar: AtomicNumeric>> Atomic<Inner>
Sourcepub fn exchange(&self, value: Inner) -> Inner
pub fn exchange(&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.
Sourcepub fn __expand_load(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
) -> <Inner as CubeType>::ExpandType
pub fn __expand_load( scope: &Scope, this: &<Self as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
Load the value of the atomic.
Sourcepub fn __expand_store(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
value: <Inner as CubeType>::ExpandType,
)
pub fn __expand_store( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, )
Store the value of the atomic.
Sourcepub fn __expand_exchange(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
value: <Inner as CubeType>::ExpandType,
) -> <Inner as CubeType>::ExpandType
pub fn __expand_exchange( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
Atomically stores the value into the atomic and returns the old value.
Sourcepub fn __expand_fetch_add(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
value: <Inner as CubeType>::ExpandType,
) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_add( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
Atomically add a number to the atomic variable. Returns the old value.
Sourcepub fn __expand_fetch_sub(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
value: <Inner as CubeType>::ExpandType,
) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_sub( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
Atomically subtracts a number from the atomic variable. Returns the old value.
Sourcepub fn __expand_fetch_max(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
value: <Inner as CubeType>::ExpandType,
) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_max( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
Atomically sets the value of the atomic variable to max(current_value, value). Returns
the old value.
Sourcepub fn __expand_fetch_min(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
value: <Inner as CubeType>::ExpandType,
) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_min( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
Atomically sets the value of the atomic variable to min(current_value, value). Returns the
old value.
Source§impl<Inner: CubePrimitive<Scalar: Int>> Atomic<Inner>
impl<Inner: CubePrimitive<Scalar: 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.
Sourcepub fn __expand_compare_exchange_weak(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
cmp: <Inner as CubeType>::ExpandType,
value: <Inner as CubeType>::ExpandType,
) -> <Inner as CubeType>::ExpandType
pub fn __expand_compare_exchange_weak( scope: &Scope, this: &<Self as CubeType>::ExpandType, cmp: <Inner as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
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 __expand_fetch_and(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
value: <Inner as CubeType>::ExpandType,
) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_and( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
Executes an atomic bitwise and operation on the atomic variable. Returns the old value.
Sourcepub fn __expand_fetch_or(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
value: <Inner as CubeType>::ExpandType,
) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_or( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
Executes an atomic bitwise or operation on the atomic variable. Returns the old value.
Sourcepub fn __expand_fetch_xor(
scope: &Scope,
this: &<Self as CubeType>::ExpandType,
value: <Inner as CubeType>::ExpandType,
) -> <Inner as CubeType>::ExpandType
pub fn __expand_fetch_xor( scope: &Scope, this: &<Self as CubeType>::ExpandType, value: <Inner as CubeType>::ExpandType, ) -> <Inner as CubeType>::ExpandType
Executes an atomic bitwise xor operation on the atomic variable. Returns the old value.
Trait Implementations§
impl<Inner: Copy + CubePrimitive> Copy for Atomic<Inner>
Source§impl<Inner: CubePrimitive> CubeDebug for Atomic<Inner>
impl<Inner: CubePrimitive> CubeDebug for Atomic<Inner>
Source§fn set_debug_name(&self, scope: &Scope, name: &'static str)
fn set_debug_name(&self, scope: &Scope, name: &'static str)
Source§impl<Inner: CubePrimitive> CubePrimitive for Atomic<Inner>
impl<Inner: CubePrimitive> CubePrimitive for Atomic<Inner>
type Scalar = <Inner as CubePrimitive>::Scalar
type Size = Const<1>
type WithScalar<S: Scalar> = Atomic<S>
fn __expand_as_type(scope: &Scope) -> TypeHandle
fn from_expand_elem(elem: ExpandValue) -> Self::ExpandType
fn from_const_value(_value: ConstantValue) -> Self
Source§fn as_type() -> TypeHandle
fn as_type() -> TypeHandle
fn into_lit_unchecked(self) -> Self
fn packing_factor() -> usize
fn vector_size() -> usize
fn __expand_size(scope: &Scope) -> usize
fn __expand_size_bits(scope: &Scope) -> usize
fn __expand_packing_factor(scope: &Scope) -> usize
fn __expand_vector_size(scope: &Scope) -> usize
Source§impl<Inner: CubePrimitive> CubeType for Atomic<Inner>
impl<Inner: CubePrimitive> CubeType for Atomic<Inner>
type ExpandType = NativeExpand<Atomic<Inner>>
impl<Inner: Eq + CubePrimitive> Eq for Atomic<Inner>
Source§impl<Inner: CubePrimitive> NativeAssign for Atomic<Inner>
impl<Inner: CubePrimitive> NativeAssign for Atomic<Inner>
fn elem_init_mut(scope: &Scope, elem: ExpandValue) -> ExpandValue
impl<Inner: PartialEq + 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> UnsafeUnpin for Atomic<Inner>where
Inner: UnsafeUnpin,
impl<Inner> UnwindSafe for Atomic<Inner>where
Inner: UnwindSafe,
Blanket Implementations§
Source§impl<T> Assign for Twhere
T: CubePrimitive,
impl<T> Assign for Twhere
T: CubePrimitive,
Source§fn __expand_assign_method(&mut self, _scope: &Scope, value: T)
fn __expand_assign_method(&mut self, _scope: &Scope, value: T)
value to self in scope.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
impl<T> CanReadValue for 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: &Scope, value: NativeExpand<From>, ) -> <Self as CubeType>::ExpandType
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneExpand for Twhere
T: Clone,
impl<T> CloneExpand for Twhere
T: Clone,
fn __expand_clone_method(&self, _: &Scope) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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