atomic_exchange
#
Defined in header <Kokkos_Atomic.hpp>
which is included from <Kokkos_Core.hpp>
Usage#
auto old = atomic_exchange(&obj, desired);
Atomically replaces the value of obj
with desired
and returns the value before the call.
Description#
-
template<class T>
T atomic_exchange(T *ptr, std::type_identity_t<T> val);# Atomically writes
val
into*ptr
and returns the original value of*ptr
.{ auto old = *ptr; *ptr = val; return old; }
- Parameters:
ptr – address of the object to modify
val – the value to store in the referenced object
- Returns:
the value held previously by the object pointed to by
ptr
See also#
atomic_load: atomically obtains the value of the referenced object
atomic_store: atomically replaces the value of the referenced object with a non-atomic argument
atomic_compare_exchange: atomically compares the value of the referenced object with non-atomic argument and performs atomic exchange if equal or atomic load if not