Template Class atomic

Class Documentation

template<typename T, MemoryScope scope = MemoryScope::SYSTEM>
class atomic

Public Functions

__host__ __device__ atomic() noexcept = default

!

__host__ __device__ constexpr atomic(T desired) noexcept
__host__ __device__ atomic(const atomic&) = delete
__host__ __device__ T operator=(T desired) noexcept

atomically assigned the desired value to the atomic variable

__host__ __device__ void store(T desired, std::memory_order = std::memory_order_seq_cst) noexcept

atomically replaces the current value with desired.

__host__ __device__ T load(std::memory_order = std::memory_order_seq_cst) const noexcept

atomically loads and returns the current value of the atomic variable

__host__ __device__ operator T() const noexcept

atomically loads and returns the current value of the atomic variable

__host__ __device__ T exchange(T desired, std::memory_order = std::memory_order_seq_cst) noexcept

atomically replaces the underlying value with desired. The operation is read-modify-write.

__host__ __device__ bool compare_exchange_strong(T &expected, T desired, std::memory_order success = std::memory_order_seq_cst, std::memory_order failure = std::memory_order_seq_cst) noexcept

atomically compares the value with expected and if those are bitwise equal, replaces the former with desired, else loads the actual value into expected.

__host__ __device__ bool compare_exchange_weak(T &expected, T desired, std::memory_order success = std::memory_order_seq_cst, std::memory_order failure = std::memory_order_seq_cst) noexcept

atomically compares the value with expected and if those are bitwise equal, replaces the former with desired, else loads the actual value into expected.

__host__ __device__ T fetch_add(T arg, std::memory_order = std::memory_order_seq_cst) noexcept

atomically replaces the curent value with the result of arithmetic addition of the value and arg. (atomic post-increment).

template<typename U_ = T, typename = std::enable_if_t<std::is_integral<U_>::value || std::is_pointer<U_>::value>>
__host__ __device__ T fetch_inc(std::memory_order = std::memory_order_seq_cst) noexcept

atomically replaces the curent value with the result of arithmetic addition of the value and 1. (atomic post-increment).

__host__ __device__ T fetch_sub(T arg, std::memory_order = std::memory_order_seq_cst) noexcept

atomically replaces the curent value with the result of arithmetic subtraction of the value and arg. (atomic post-decrement).

__host__ __device__ T fetch_and(T arg, std::memory_order = std::memory_order_seq_cst) noexcept

atomically replaces the curent value with the result of bitwise And of the value and arg.

__host__ __device__ T fetch_or(T arg, std::memory_order = std::memory_order_seq_cst) noexcept

atomically replaces the curent value with the result of bitwise Or of the value and arg.

__host__ __device__ T fetch_xor(T arg, std::memory_order = std::memory_order_seq_cst) noexcept

atomically replaces the curent value with the result of bitwise Xor of the value and arg.

__host__ __device__ T operator+=(T arg) noexcept

Adds with the atomic value.

__host__ __device__ T operator-=(T arg) noexcept

Subtracts with the atomic value.

__host__ __device__ T operator&=(T arg) noexcept

Performs bitwise And with the atomic value.

__host__ __device__ T operator|=(T arg) noexcept

Performs bitwise Or with the atomic value.

__host__ __device__ T operator^=(T arg) noexcept

Performs bitwise XOr with the atomic value.

template<typename U_ = T, typename = std::enable_if_t<std::is_integral<U_>::value || std::is_pointer<U_>::value>>
__host__ __device__ T operator++() noexcept

Performs atomic pre-increment.

template<typename U_ = T, typename = std::enable_if_t<std::is_integral<U_>::value || std::is_pointer<U_>::value>>
__host__ __device__ T operator++(int) noexcept

Performs atomic post-increment.

template<typename U_ = T, typename = std::enable_if_t<std::is_integral<U_>::value || std::is_pointer<U_>::value>>
__host__ __device__ T operator--() noexcept

Performs atomic pre-decrement.

template<typename U_ = T, typename = std::enable_if_t<std::is_integral<U_>::value || std::is_pointer<U_>::value>>
__host__ __device__ T operator--(int) noexcept

Performs atomic post-decrement.