The OpenD Programming Language

Atomic

This is a D version of a partial implementation of the std::atomic template found in C++ STL. https://en.cppreference.com/w/cpp/atomic/atomic

Constructors

this
this(T val)

Initializes the underlying object with desired value. The initialization is not atomic.

this
this(Atomic rhs)

Copy constructor is disabled because an atomic cannot be passed to functions as a copy and copy it around will break the whole point of an atomic.

Alias This

load

Atomically load the current value.

Params: val = desired value

Members

Functions

compareExchangeStrong
bool compareExchangeStrong(T expected, T desired)

Atomically compares the atomic value with that of expected. If those are bitwise-equal, replaces the former with desired (performs read-modify-write operation). Otherwise, loads the actual atomic value stored into expected (performs load operation).

compareExchangeWeak
bool compareExchangeWeak(T expected, T desired)

Atomically compares the atomic value with that of expected. If those are bitwise-equal, replaces the former with desired (performs read-modify-write operation). Otherwise, loads the actual atomic value stored into expected (performs load operation).

exchange
T exchange(T newVal)

Atomically replaces the underlying value with a desired value (a read-modify-write operation). Memory is affected according to the value of order.

fetchAdd
T fetchAdd(T val)

Atomically replaces the current value with the result of arithmetic addition of the atomic variable and val. That is, it performs atomic post-increment. The operation is a read-modify-write operation. Memory is affected according to the value of order.

fetchAnd
T fetchAnd(T val)

Atomically replaces the current value with the result of bitwise AND of the the atomic value and val. The operation is read-modify-write operation. Memory is affected according to the value of order.

fetchOr
T fetchOr(T val)

Atomically replaces the current value with the result of bitwise OR of the the atomic value and val. The operation is read-modify-write operation. Memory is affected according to the value of order.

fetchSub
T fetchSub(T val)

Atomically replaces the current value with the result of arithmetic subtraction of the atomic variable and val. That is, it performs atomic post-decrment. The operation is a read-modify-write operation. Memory is affected according to the value of order.

fetchXor
T fetchXor(T val)

Atomically replaces the current value with the result of bitwise XOR of the the atomic value and val. The operation is read-modify-write operation. Memory is affected according to the value of order.

load
T load()

Loads the atomic value from memory and returns it. The memory barrier specified by 'order' is applied to the operation, which is fully sequenced by default. Valid memory orders are MemoryOrder.raw, MemoryOrder.acq, and MemoryOrder.seq.

opAssign
void opAssign(T val)

Atomically replaces the current value with a desired value.

opOpAssign
T opOpAssign(T val)

Atomically replaces the current value with the result of computation involving the previous value and val. The operation is read-modify-write operation.

opUnary
T opUnary()

Atomically increments or decrements the current value. The operation is read-modify-write operation.

opUnaryRight
T opUnaryRight()

Atomically increments or decrements the current value. The operation is read-modify-write operation.

store
void store(T val)

Atomically replaces the current value with a desired value. Memory is affected according to the value of order.

Meta