compare_exchange_strong

compare_exchange_strong#

stdgpu: stdgpu::atomic_ref::compare_exchange_strong
stdgpu Latest
Efficient STL-like Data Structures on the GPU

◆ compare_exchange_strong()

template<typename T >
STDGPU_DEVICE_ONLY bool stdgpu::atomic_ref< T >::compare_exchange_strong ( T &  expected,
const T  desired,
const memory_order  order = memory_order_seq_cst 
)
noexcept

Atomically compares the current value with the given value and exchanges it with the desired one in case the both values are equal.

Parameters
[in]expectedA reference to the value to expect in the atomic object, will be updated with old value if it has not been changed
[in]desiredThe value to exchange with the atomic object
[in]orderThe memory order
Returns
True if the value has been changed to desired, false otherwise