CopperSpice API
1.9.2
|
The QAtomicInt class provides platform independent atomic operations on integers. More...
Public Methods | |
QAtomicInt (const QAtomicInt &other) | |
QAtomicInt (int value) | |
bool | compareExchange (int &expectedValue, int newValue, std::memory_order order1=std::memory_order_seq_cst, std::memory_order order2=std::memory_order_seq_cst) |
bool | compareExchangeWeak (int &expectedValue, int newValue, std::memory_order order1=std::memory_order_seq_cst, std::memory_order order2=std::memory_order_seq_cst) |
bool | deref () |
int | fetchAndAddAcquire (int valueToAdd) |
int | fetchAndAddOrdered (int valueToAdd) |
int | fetchAndAddRelaxed (int valueToAdd) |
int | fetchAndAddRelease (int valueToAdd) |
int | fetchAndStoreAcquire (int newValue) |
int | fetchAndStoreOrdered (int newValue) |
int | fetchAndStoreRelaxed (int newValue) |
int | fetchAndStoreRelease (int newValue) |
int | load () const |
int | load (std::memory_order order) const |
int | loadAcquire () const |
int | operator++ () |
int | operator++ (int) |
int | operator+= (int value) |
int | operator-- () |
int | operator-- (int) |
int | operator-= (int value) |
QAtomicInt & | operator= (const QAtomicInt &other) |
QAtomicInt & | operator= (int value) |
bool | ref () |
void | store (int newValue) |
void | store (int newValue, std::memory_order order) |
void | storeRelease (int newValue) |
bool | testAndSetAcquire (int expectedValue, int newValue) |
bool | testAndSetOrdered (int expectedValue, int newValue) |
bool | testAndSetRelaxed (int expectedValue, int newValue) |
bool | testAndSetRelease (int expectedValue, int newValue) |
Static Public Methods | |
static bool | isFetchAndAddNative () |
static bool | isFetchAndAddWaitFree () |
static bool | isFetchAndStoreNative () |
static bool | isFetchAndStoreWaitFree () |
static bool | isReferenceCountingNative () |
static bool | isReferenceCountingWaitFree () |
static bool | isTestAndSetNative () |
static bool | isTestAndSetWaitFree () |
The QAtomicInt class provides platform independent atomic operations on integers. For atomic operations on pointers refer to the QAtomicPointer class. An atomic operation is one which is guaranteed to free of data races.
This class has several methods which have a parameter which specifies the memory ordering. These are the valid enum values.
Value | Description |
---|---|
std::memory_order_relaxed | memory ordering is unrestricted, allows the compiler and processor to freely reorder non atomic memory access |
std::memory_order_acquire | prevents all read and writes of non atomic data from being moved before the current atomic operation |
std::memory_order_release | prevents all read and writes of non atomic data from being moved after the current atomic operation |
std::memory_order_acq_rel | combination of acquire and release |
std::memory_order_seq_cst | default ordering, all reads and writes will done in the same order as the appear in the source code |
If the current atomic value is equal to the expected value then compareExchange() will store the new value and return true. If the current atomic value is not equal to the expected value compareExchange() will be updated with the current atomic value and this method will return false.
The atomic "fetch and store" methods assign the new value and returns the original value.
The atomic "fetch and add" methods add the given value to the current atomic value and return the original value.
|
inline |
Constructs a new QAtomicInt with the given value.
|
inline |
Copy constructs a new QAtomicInt from other.
|
inline |
If the current atomic value is equal to the expectedValue, this method will store the new value and return true.
If the current atomic value is not equal to the expected value, will be updated with the current atomic value and this method will return false.
This method uses the strong compare exchange operation.
|
inline |
If the current atomic value is equal to the expectedValue, then method will store the new value and return true. If the current atomic value is not equal to the expected value, will be updated with the current atomic value and this method will return false.
This method uses the weak compare exchange operation. If the operation returns false it is possible the expected value did match however there was some other conflict. If this happens the operation should be retried.
|
inline |
Atomically decrements the value of this QAtomicInt. Returns true if the new value is non-zero, false otherwise.
This method uses ordered memory ordering semantics, which ensures that memory access before and after the atomic operation (in program order) may not be reordered.
|
inline |
Reads the current value of this QAtomicInt and then adds valueToAdd to the current value, returns the original value.
This method uses acquire memory ordering semantics, which ensures that memory access following the atomic operation (in program order) may not be reordered before the atomic operation.
|
inline |
Reads the current value of this QAtomicInt and then adds valueToAdd to the current value, returns the original value.
This method uses ordered memory ordering semantics which ensures that memory access before and after the atomic operation (in program order) may not be reordered.
|
inline |
Reads the current value of this QAtomicInt and then adds valueToAdd to the current value, returns the original value.
This method uses relaxed memory ordering semantics leaving the compiler and processor to freely reorder memory accesses.
|
inline |
Reads the current value of this QAtomicInt and then adds valueToAdd to the current value, returns the original value.
This method uses release memory ordering semantics which ensures that memory access before the atomic operation (in program order) may not be reordered after the atomic operation.
|
inline |
Reads the current value of this QAtomicInt and then assigns newValue to this object, returns the original value.
This method uses acquire memory ordering semantics which ensures that memory access following the atomic operation (in program order) may not be reordered before the atomic operation.
|
inline |
Reads the current value of this QAtomicInt and then assigns newValue to this object, returns the original value.
This method uses ordered memory ordering semantics, which ensures that memory access before and after the atomic operation (in program order) may not be reordered.
|
inline |
Reads the current value of this QAtomicInt and then assigns newValue to this object, returns the original value.
This method uses relaxed memory ordering semantics leaving the compiler and processor to freely reorder memory accesses.
|
inline |
Reads the current value of this QAtomicInt and then assigns newValue to this object, returns the original value.
This method uses release memory ordering semantics, which ensures that memory access before the atomic operation (in program order) may not be reordered after the atomic operation.
|
inlinestatic |
Returns true if "fetch and add" is implemented using atomic processor instructions, otherwise returns false.
|
inlinestatic |
Returns true if atomic "fetch and add" is wait free, otherwise returns false.
|
inlinestatic |
Returns true if "fetch and store" is implemented using atomic processor instructions, otherwise returns false.
|
inlinestatic |
Returns true if atomic "fetch and store" is wait free, otherwise returns false.
|
inlinestatic |
Returns true if reference counting is implemented using atomic processor instructions, otherwise returns false.
|
inlinestatic |
Returns true if atomic reference counting is wait free, otherwise returns false.
|
inlinestatic |
Returns true if "test and set" is implemented using atomic processor instructions, otherwise returns false.
|
inlinestatic |
Returns true if atomic "test and set" is wait free, otherwise returns false.
|
inline |
Atomically loads the value of this QAtomicInt using relaxed memory ordering.
|
inline |
Atomically loads the value of this QAtomicInt using the memory ordering order.
|
inline |
|
inline |
The prefix ++ operator advances the atomic to the next item in memory and returns the new value.
|
inline |
The postfix ++ operator advances the atomic to the next item in memory and returns the old value.
|
inline |
Add value to current atomic and returns the new value.
|
inline |
The prefix – operator decrements the atomic to the previous item in memory and returns the new value.
|
inline |
The postfix – operator decrements the atomic to the previous item in memory and returns the old value.
|
inline |
Subtracts value from the current atomic and returns the new value.
|
inline |
Copy assigns from other and returns a reference to this object.
|
inline |
Assigns value to this QAtomicInt and returns a reference to this object.
|
inline |
Atomically increments the value of this QAtomicInt. Returns true if the new value is non-zero, otherwise returns false.
This method uses ordered memory ordering semantics which ensures that memory access before and after the atomic operation (in program order) may not be reordered.
|
inline |
Atomically stores the newValue value into this atomic type using relaxed memory ordering.
|
inline |
Atomically stores the newValue value into this atomic type using the memory ordering order.
|
inline |
|
inlinedeprecated |
If the current value of this QAtomicInt is the expectedValue, the test-and-set methods assign the newValue to this QAtomicInt and returns true. If the values are not the same this method does nothing and returns false.
This method uses acquire memory ordering semantics which ensures that memory access following the atomic operation (in program order) may not be reordered before the atomic operation.
|
inlinedeprecated |
If the current value of this QAtomicInt is the expectedValue, the test-and-set methods assign the newValue to this QAtomicInt and returns true. If the values are not the same this method does nothing and returns false.
This method uses ordered memory ordering semantics which ensures that memory access before and after the atomic operation (in program order) may not be reordered.
|
inlinedeprecated |
If the current value of this QAtomicInt is the expectedValue, the test-and-set methods assign the newValue to this QAtomicInt and returns true. If the values are not the same this method does nothing and returns false.
This method uses relaxed memory ordering semantics leaving the compiler and processor to freely reorder memory accesses.
|
inlinedeprecated |
If the current value of this QAtomicInt is the expectedValue, the test-and-set methods assign the newValue to this QAtomicInt and returns true. If the values are not the same this method does nothing and returns false.
This method uses release memory ordering semantics which ensures that memory access before the atomic operation (in program order) may not be reordered after the atomic operation.