• Slang Standard Library Reference
    • Interfaces
    • Types
      • Buffer types
      • Math types
      • Miscelaneous types
      • Ray-tracing
      • Sampler types
      • Scalar types
      • Stage IO types
      • Texture types
      • Array
      • Atomic
        • add
        • and
        • compareExchange
        • decrement
        • exchange
        • increment
        • load
        • max
        • min
        • or
        • store
        • sub
        • xor
      • AtomicAdd
      • BindlessDescriptorOptions
      • ConstantBuffer
      • CoopMat
      • CoopMatClampMode
      • CoopMatMatrixLayout
      • CoopMatMatrixUse
      • CoopVec
      • CoopVecComponentType
      • CoopVecMatrixLayout
      • DefaultVkBindlessBindings
      • DescriptorAccess
      • DescriptorHandle
      • DescriptorKind
      • DiffTensorView
      • DifferentialPair
      • DifferentialPtrPair
      • DispatchNodeInputRecord
      • MemoryScope
      • NodePayloadPtr
      • NullDifferential
      • Optional
      • ParameterBlock
      • Ptr
      • String
      • TensorLayout
      • TensorView
      • TorchTensor
      • Tuple
      • VkMutableBindlessBindings
      • _AttributeTargets
      • int8_t4_packed
      • uint8_t4_packed
    • Attributes
    • Global Declarations

Atomic<T>.compareExchange

Description

Atomically replace and return the stored T value with a new T value only if the stored value is equal to the specified comparison value.

If the comparison value is equal to the stored value, then the successOrder MemoryOrder is used, otherwise the failOrder MemoryOrder is used.

successOrder must be at least as strong as failOrder

failOrder must not be MemoryOrder.Release or MemoryOrder.AcquireRelease

Signature

T Atomic<T>.compareExchange(
    T compareValue,
    T newValue,
    MemoryOrder successOrder,
    MemoryOrder failOrder)
    where T : IAtomicable;

Parameters

compareValue : T

newValue : T

successOrder : MemoryOrder = MemoryOrder.Relaxed

failOrder : MemoryOrder = MemoryOrder.Relaxed