fennec
Loading...
Searching...
No Matches
fennec::atomic< T >

Wrapper for atomic variables. More...

#include <atomic.h>

Detailed Description

template<typename T>
struct fennec::atomic< T >
Template Parameters
TThe type of the atomic variable

Public Member Functions

constexpr atomic () noexcept
 Default Constructor.
 
constexpr atomic (const T value) noexcept
 Value Constructor.
 
operator= (const T x) noexcept
 
operator= (const T x) volatile noexcept
 Stores a value into an atomic object.
 
void store (const T x, memory_order order=memory_order_seq_cst) noexcept
 
void store (const T x, memory_order order=memory_order_seq_cst) volatile noexcept
 Atomically replaces the value of the atomic object with a non-atomic argument.
 
load (memory_order order=memory_order_seq_cst) const noexcept
 
load (memory_order order=memory_order_seq_cst) const volatile noexcept
 Atomically obtains the value of the atomic object.
 
 operator T () const noexcept
 
 operator T () const volatile noexcept
 Loads a value from an atomic object.
 
exchange (const T x, memory_order order=memory_order_seq_cst) noexcept
 
exchange (const T x, memory_order order=memory_order_seq_cst) volatile noexcept
 Atomically replaces the value of the atomic object and obtains the value held previously.
 
bool compare_exchange_weak (T &exp, T x, memory_order succ, memory_order fail) noexcept
 
bool compare_exchange_weak (T &exp, T x, memory_order succ, memory_order fail) volatile noexcept
 
bool compare_exchange_weak (T &exp, T x, memory_order order=memory_order_seq_cst) noexcept
 
bool compare_exchange_weak (T &exp, T x, memory_order order=memory_order_seq_cst) volatile noexcept
 Atomically compares the value of the atomic object with non-atomic argument and performs atomic exchange if equal or atomic load if not.
 
bool compare_exchange_strong (T &exp, T x, memory_order succ, memory_order fail) noexcept
 
bool compare_exchange_strong (T &exp, T x, memory_order succ, memory_order fail) volatile noexcept
 
bool compare_exchange_strong (T &exp, T x, memory_order order=memory_order_seq_cst) noexcept
 
bool compare_exchange_strong (T &exp, T x, memory_order order=memory_order_seq_cst) volatile noexcept
 Atomically compares the value of the atomic object with non-atomic argument and performs atomic exchange if equal or atomic load if not.
 

Constructor & Destructor Documentation

◆ atomic() [1/2]

template<typename T >
constexpr fennec::atomic< T >::atomic ( )
inlineconstexprnoexcept

Initializes the held atomic variable with 0.

◆ atomic() [2/2]

template<typename T >
constexpr fennec::atomic< T >::atomic ( const T  value)
inlineconstexprnoexcept

Initializes the held atomic variable with value.

Parameters
valueThe value to initialize the atomic variable with.

Member Function Documentation

◆ operator=() [1/2]

template<typename T >
T fennec::atomic< T >::operator= ( const T  x)
inlinenoexcept

Atomically assigns x to the atomic variable.

Parameters
xThe value to assign
Returns
x

◆ operator=() [2/2]

template<typename T >
T fennec::atomic< T >::operator= ( const T  x) volatile
inlinenoexcept

Atomically assigns x to the atomic variable.

Parameters
xThe value to assign
Returns
x

◆ store() [1/2]

template<typename T >
void fennec::atomic< T >::store ( const T  x,
memory_order  order = memory_order_seq_cst 
)
inlinenoexcept

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

Parameters
xThe value to store into the atomic variable
orderMemory order constraints to enforce

◆ store() [2/2]

template<typename T >
void fennec::atomic< T >::store ( const T  x,
memory_order  order = memory_order_seq_cst 
) volatile
inlinenoexcept

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

Parameters
xThe value to store into the atomic variable
orderMemory order constraints to enforce

◆ load() [1/2]

template<typename T >
T fennec::atomic< T >::load ( memory_order  order = memory_order_seq_cst) const
inlinenoexcept

Atomically loads and returns the current value of the atomic variable. Memory is affected according to the value of order.

Parameters
orderMemory order constraints to enforce
Returns
The current value of the atomic variable.

◆ load() [2/2]

template<typename T >
T fennec::atomic< T >::load ( memory_order  order = memory_order_seq_cst) const volatile
inlinenoexcept

Atomically loads and returns the current value of the atomic variable. Memory is affected according to the value of order.

Parameters
orderMemory order constraints to enforce
Returns
The current value of the atomic variable.

◆ operator T() [1/2]

template<typename T >
fennec::atomic< T >::operator T ( ) const
inlinenoexcept

Atomically loads and returns the current value of the atomic variable. Equivalent to load().

◆ operator T() [2/2]

template<typename T >
fennec::atomic< T >::operator T ( ) const volatile
inlinenoexcept

Atomically loads and returns the current value of the atomic variable. Equivalent to load().

◆ exchange() [1/2]

template<typename T >
T fennec::atomic< T >::exchange ( const T  x,
memory_order  order = memory_order_seq_cst 
)
inlinenoexcept

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

Parameters
xValue to assign
orderMemory order constraints to enforce
Returns
The value of the atomic variable before the call.

◆ exchange() [2/2]

template<typename T >
T fennec::atomic< T >::exchange ( const T  x,
memory_order  order = memory_order_seq_cst 
) volatile
inlinenoexcept

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

Parameters
xValue to assign
orderMemory order constraints to enforce
Returns
The value of the atomic variable before the call.

◆ compare_exchange_weak() [1/4]

template<typename T >
bool fennec::atomic< T >::compare_exchange_weak ( T &  exp,
x,
memory_order  succ,
memory_order  fail 
)
inlinenoexcept

Atomically compares the value of *this with that of exp. If they are equal, replaces the former with x (performs read-modify-write operation). Otherwise, loads the actual value stored in *this into exp (performs load operation).

Parameters
expReference to the value expected to be found in the atomic object.
xThe value to store in the atomic object if it is as expected.
succThe memory synchronization ordering for the read-modify-write operation if the comparison succeeds.
failThe memory synchronization ordering for the load operation if the comparison fails.
orderThe memory synchronization ordering for both operations.
Returns
true if the underlying atomic value was successfully changed, false otherwise.

◆ compare_exchange_weak() [2/4]

template<typename T >
bool fennec::atomic< T >::compare_exchange_weak ( T &  exp,
x,
memory_order  succ,
memory_order  fail 
) volatile
inlinenoexcept

Atomically compares the value of *this with that of exp. If they are equal, replaces the former with x (performs read-modify-write operation). Otherwise, loads the actual value stored in *this into exp (performs load operation).

Parameters
expReference to the value expected to be found in the atomic object.
xThe value to store in the atomic object if it is as expected.
succThe memory synchronization ordering for the read-modify-write operation if the comparison succeeds.
failThe memory synchronization ordering for the load operation if the comparison fails.
orderThe memory synchronization ordering for both operations.
Returns
true if the underlying atomic value was successfully changed, false otherwise.

◆ compare_exchange_weak() [3/4]

template<typename T >
bool fennec::atomic< T >::compare_exchange_weak ( T &  exp,
x,
memory_order  order = memory_order_seq_cst 
)
inlinenoexcept

Atomically compares the value of *this with that of exp. If they are equal, replaces the former with x (performs read-modify-write operation). Otherwise, loads the actual value stored in *this into exp (performs load operation).

Parameters
expReference to the value expected to be found in the atomic object.
xThe value to store in the atomic object if it is as expected.
succThe memory synchronization ordering for the read-modify-write operation if the comparison succeeds.
failThe memory synchronization ordering for the load operation if the comparison fails.
orderThe memory synchronization ordering for both operations.
Returns
true if the underlying atomic value was successfully changed, false otherwise.

◆ compare_exchange_weak() [4/4]

template<typename T >
bool fennec::atomic< T >::compare_exchange_weak ( T &  exp,
x,
memory_order  order = memory_order_seq_cst 
) volatile
inlinenoexcept

Atomically compares the value of *this with that of exp. If they are equal, replaces the former with x (performs read-modify-write operation). Otherwise, loads the actual value stored in *this into exp (performs load operation).

Parameters
expReference to the value expected to be found in the atomic object.
xThe value to store in the atomic object if it is as expected.
succThe memory synchronization ordering for the read-modify-write operation if the comparison succeeds.
failThe memory synchronization ordering for the load operation if the comparison fails.
orderThe memory synchronization ordering for both operations.
Returns
true if the underlying atomic value was successfully changed, false otherwise.

◆ compare_exchange_strong() [1/4]

template<typename T >
bool fennec::atomic< T >::compare_exchange_strong ( T &  exp,
x,
memory_order  succ,
memory_order  fail 
)
inlinenoexcept

Atomically compares the value of *this with that of exp. If they are equal, replaces the former with x (performs read-modify-write operation). Otherwise, loads the actual value stored in *this into exp (performs load operation).

Parameters
expReference to the value expected to be found in the atomic object.
xThe value to store in the atomic object if it is as expected.
succThe memory synchronization ordering for the read-modify-write operation if the comparison succeeds.
failThe memory synchronization ordering for the load operation if the comparison fails.
orderThe memory synchronization ordering for both operations.
Returns
true if the underlying atomic value was successfully changed, false otherwise.

◆ compare_exchange_strong() [2/4]

template<typename T >
bool fennec::atomic< T >::compare_exchange_strong ( T &  exp,
x,
memory_order  succ,
memory_order  fail 
) volatile
inlinenoexcept

Atomically compares the value of *this with that of exp. If they are equal, replaces the former with x (performs read-modify-write operation). Otherwise, loads the actual value stored in *this into exp (performs load operation).

Parameters
expReference to the value expected to be found in the atomic object.
xThe value to store in the atomic object if it is as expected.
succThe memory synchronization ordering for the read-modify-write operation if the comparison succeeds.
failThe memory synchronization ordering for the load operation if the comparison fails.
orderThe memory synchronization ordering for both operations.
Returns
true if the underlying atomic value was successfully changed, false otherwise.

◆ compare_exchange_strong() [3/4]

template<typename T >
bool fennec::atomic< T >::compare_exchange_strong ( T &  exp,
x,
memory_order  order = memory_order_seq_cst 
)
inlinenoexcept

Atomically compares the value of *this with that of exp. If they are equal, replaces the former with x (performs read-modify-write operation). Otherwise, loads the actual value stored in *this into exp (performs load operation).

Parameters
expReference to the value expected to be found in the atomic object.
xThe value to store in the atomic object if it is as expected.
succThe memory synchronization ordering for the read-modify-write operation if the comparison succeeds.
failThe memory synchronization ordering for the load operation if the comparison fails.
orderThe memory synchronization ordering for both operations.
Returns
true if the underlying atomic value was successfully changed, false otherwise.

◆ compare_exchange_strong() [4/4]

template<typename T >
bool fennec::atomic< T >::compare_exchange_strong ( T &  exp,
x,
memory_order  order = memory_order_seq_cst 
) volatile
inlinenoexcept

Atomically compares the value of *this with that of exp. If they are equal, replaces the former with x (performs read-modify-write operation). Otherwise, loads the actual value stored in *this into exp (performs load operation).

Parameters
expReference to the value expected to be found in the atomic object.
xThe value to store in the atomic object if it is as expected.
succThe memory synchronization ordering for the read-modify-write operation if the comparison succeeds.
failThe memory synchronization ordering for the load operation if the comparison fails.
orderThe memory synchronization ordering for both operations.
Returns
true if the underlying atomic value was successfully changed, false otherwise.

The documentation for this struct was generated from the following file: