Quick Links: |
#include <bsls_atomic.h>
Public Member Functions | |
AtomicBool () | |
AtomicBool (bool value) | |
~AtomicBool () | |
AtomicBool & | operator= (bool value) |
void | store (bool value) |
void | storeRelaxed (bool value) |
void | storeRelease (bool value) |
bool | swap (bool swapValue) |
bool | swapAcqRel (bool swapValue) |
bool | testAndSwap (bool compareValue, bool swapValue) |
bool | testAndSwapAcqRel (bool compareValue, bool swapValue) |
operator bool () const | |
bool | load () const |
bool | loadRelaxed () const |
bool | loadAcquire () const |
This class implements an atomic boolean, which supports common boolean operations in a way that is guaranteed to be atomic. Operations on objects of this class provide the sequential consistency memory ordering guarantee unless explicitly qualified with a less strict consistency guarantee suffix (i.e., Acquire, Release, AcqRel or Relaxed).
bsls::AtomicBool::AtomicBool | ( | ) |
Create an atomic boolean object having the default value false
.
bsls::AtomicBool::AtomicBool | ( | bool | value | ) |
Create an atomic boolean object having the specified value
.
bsls::AtomicBool::~AtomicBool | ( | ) |
Destroy this atomic boolean object.
AtomicBool& bsls::AtomicBool::operator= | ( | bool | value | ) |
Atomically assign the specified value
to this object, and return a reference offering modifiable access to this
object.
void bsls::AtomicBool::store | ( | bool | value | ) |
Atomically assign the specified value
to this object, providing the sequential consistency memory ordering guarantee.
void bsls::AtomicBool::storeRelaxed | ( | bool | value | ) |
Atomically assign the specified value
to this object, providing the relaxed memory ordering guarantee.
void bsls::AtomicBool::storeRelease | ( | bool | value | ) |
Atomically assign the specified value
to this object, providing the release memory ordering guarantee.
bool bsls::AtomicBool::swap | ( | bool | swapValue | ) |
Atomically set the value of this object to the specified swapValue
and return its previous value.
bool bsls::AtomicBool::swapAcqRel | ( | bool | swapValue | ) |
Atomically set the value of this object to the specified swapValue
and return its previous value, providing the acquire/release memory ordering guarantee.
bool bsls::AtomicBool::testAndSwap | ( | bool | compareValue, | |
bool | swapValue | |||
) |
Compare the value of this object to the specified compareValue
. If they are equal, set the value of this atomic boolean to the specified swapValue
, otherwise leave this value unchanged. Return the previous value of this atomic boolean, whether or not the swap occurred. Note that the entire test-and-swap operation is performed atomically.
bool bsls::AtomicBool::testAndSwapAcqRel | ( | bool | compareValue, | |
bool | swapValue | |||
) |
Compare the value of this object to the specified compareValue
. If they are equal, set the value of this atomic boolean to the specified swapValue
, otherwise leave this value unchanged. Return the previous value of this atomic boolean, whether or not the swap occurred. Note that the entire test-and-swap operation is performed atomically and it provides the acquire/release memory ordering guarantee.
bsls::AtomicBool::operator bool | ( | ) | const |
Return the current value of this object.
bool bsls::AtomicBool::load | ( | ) | const |
Return the current value of this object.
bool bsls::AtomicBool::loadRelaxed | ( | ) | const |
Return the current value of this object, providing the relaxed memory ordering guarantee.
bool bsls::AtomicBool::loadAcquire | ( | ) | const |
Return the current value of this object, providing the acquire memory ordering guarantee.