![]() |
GemaCoreLib
The GeMA Core library
|
A simple spin lock implementation based on a loop using test and set over an atomic int to change its value from 0 to 1. More...
#include <gmSpinLock.h>
Public Member Functions | |
GmSpinLock () | |
Constructor. | |
void | lock () |
Aquires the lock. | |
bool | tryLock () |
Try to lock. Returns true if the lock was aquired, false otherwise. | |
void | unlock () |
Releases the lock. | |
![]() | |
QAtomicInt (int value) | |
![]() | |
QAtomicInteger (T value) | |
QAtomicInteger (const QAtomicInteger< T > &other) | |
QAtomicInteger< T > & | operator= (const QAtomicInteger< T > &other) |
T | load () const const |
T | loadAcquire () const const |
void | store (T newValue) |
void | storeRelease (T newValue) |
T | operator T () const const |
QAtomicInteger< T > & | operator= (T) |
bool | ref () |
bool | deref () |
bool | testAndSetRelaxed (T expectedValue, T newValue) |
bool | testAndSetAcquire (T expectedValue, T newValue) |
bool | testAndSetRelease (T expectedValue, T newValue) |
bool | testAndSetOrdered (T expectedValue, T newValue) |
T | fetchAndStoreRelaxed (T newValue) |
T | fetchAndStoreAcquire (T newValue) |
T | fetchAndStoreRelease (T newValue) |
T | fetchAndStoreOrdered (T newValue) |
T | fetchAndAddRelaxed (T valueToAdd) |
T | fetchAndAddAcquire (T valueToAdd) |
T | fetchAndAddRelease (T valueToAdd) |
T | fetchAndAddOrdered (T valueToAdd) |
T | fetchAndSubRelaxed (T valueToSub) |
T | fetchAndSubAcquire (T valueToSub) |
T | fetchAndSubRelease (T valueToSub) |
T | fetchAndSubOrdered (T valueToSub) |
T | fetchAndOrRelaxed (T valueToOr) |
T | fetchAndOrAcquire (T valueToOr) |
T | fetchAndOrRelease (T valueToOr) |
T | fetchAndOrOrdered (T valueToOr) |
T | fetchAndAndRelaxed (T valueToAnd) |
T | fetchAndAndAcquire (T valueToAnd) |
T | fetchAndAndRelease (T valueToAnd) |
T | fetchAndAndOrdered (T valueToAnd) |
T | fetchAndXorRelaxed (T valueToXor) |
T | fetchAndXorAcquire (T valueToXor) |
T | fetchAndXorRelease (T valueToXor) |
T | fetchAndXorOrdered (T valueToXor) |
T | operator++ () |
T | operator++ (int) |
T | operator-- () |
T | operator-- (int) |
T | operator+= (T value) |
T | operator-= (T value) |
T | operator|= (T value) |
T | operator&= (T value) |
T | operator^= (T value) |
Additional Inherited Members | |
![]() | |
bool | isReferenceCountingNative () |
bool | isReferenceCountingWaitFree () |
bool | isTestAndSetNative () |
bool | isTestAndSetWaitFree () |
bool | isFetchAndStoreNative () |
bool | isFetchAndStoreWaitFree () |
bool | isFetchAndAddNative () |
bool | isFetchAndAddWaitFree () |
A simple spin lock implementation based on a loop using test and set over an atomic int to change its value from 0 to 1.
TODO: See some ideas in https://geidav.wordpress.com/2016/03/23/test-and-set-spinlocks/ to improve the lock efficiency by, for example, emmitting a pause instruction in the loop.