atomic_compare_exchange_weak

atomic_compare_exchange_weak#

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

◆ atomic_compare_exchange_weak()

template<typename T , typename Allocator >
STDGPU_DEVICE_ONLY bool stdgpu::atomic_compare_exchange_weak ( atomic< T, Allocator > *  obj,
typename atomic< T, Allocator >::value_type *  expected,
const typename atomic< T, Allocator >::value_type  desired 
)
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]objThe atomic object
[in]expectedA pointer 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
Returns
True if the value has been changed to desired, false otherwise