C12Adapter Opensource C++ Interface
|
System independent lightweight synchronization object that synchronizes the access to one variable across multiple threads. More...
Public Types | |
typedef int | ValueType |
Type used by interlocked class by default. | |
Public Member Functions | |
MInterlocked (int value=0) | |
Constructor of the interlocked variable. More... | |
MInterlocked (const MInterlocked &other) | |
Copy constructor that copies value from parameter. More... | |
MInterlocked & | operator= (int value) |
Assignment operator that takes integer value. More... | |
MInterlocked & | operator= (const MInterlocked &other) |
Object assignment operator. More... | |
operator int () const | |
Access the value of the interlocked class. More... | |
int | operator++ () |
Atomically increment this object value and return result. More... | |
int | operator++ (int) |
Atomically increment this object value and return previous value. More... | |
int | operator-- () |
Atomically decrement this object value and return result. More... | |
int | operator-- (int) |
Atomically decrement this object value and return previous value. More... | |
Static Public Member Functions | |
static int | IncrementAndFetch (volatile int *v) |
Static function that atomically increments an integer in the given pointer and returns the new value. More... | |
static int | FetchAndIncrement (volatile int *v) |
Static function that atomically increments an integer in the given pointer and returns the previous value. More... | |
static int | DecrementAndFetch (volatile int *v) |
Static function that atomically decrements an integer in the given pointer and returns the new value. More... | |
static int | FetchAndDecrement (volatile int *v) |
Static function that atomically decrements an integer in the given pointer and returns the previous value. More... | |
System independent lightweight synchronization object that synchronizes the access to one variable across multiple threads.
At present, the only atomic operations supported are increment and decrement.
Implementation note: On the majority of architectures, assignment to and from a properly aligned unsigned variable is an atomic operation.
|
inline |
Constructor of the interlocked variable.
value | Initial value of interlocked variable |
|
inline |
Copy constructor that copies value from parameter.
If during this operation the value of the other object keeps changing, the result value will be consistent, correspond to some value that was held by other object at an unknown time of the copy operation.
other | Interlocked object from which to copy value |
|
inlinestatic |
Static function that atomically decrements an integer in the given pointer and returns the new value.
This operation should be used in multithreaded environments in order to prevent situations when multiple threads would fail to change the same value in a consistent way.
v | Volatile pointer to the integer that should be decremented |
|
inlinestatic |
Static function that atomically decrements an integer in the given pointer and returns the previous value.
This operation should be used in multithreaded environments in order to prevent situations when multiple threads would fail to change the same value in a consistent way.
v | Volatile pointer to the integer that should be decremented |
|
inlinestatic |
Static function that atomically increments an integer in the given pointer and returns the previous value.
This operation should be used in multithreaded environments in order to prevent situations when multiple threads would fail to change the same value in a consistent way.
v | Volatile pointer to the integer that should be incremented |
|
inlinestatic |
Static function that atomically increments an integer in the given pointer and returns the new value.
This operation should be used in multithreaded environments in order to prevent situations when multiple threads would fail to change the same value in a consistent way.
v | Volatile pointer to the integer that should be incremented |
|
inline |
Access the value of the interlocked class.
If the object keeps changing from other threads, the result will be a consistent value at some definite but unknown period of time.
|
inline |
Atomically increment this object value and return result.
This operation should be used in multithreaded environments in order to prevent situations when multiple threads would fail to change the same value in a consistent way.
|
inline |
Atomically increment this object value and return previous value.
This operation should be used in multithreaded environments in order to prevent situations when multiple threads would fail to change the same value in a consistent way.
|
inline |
Atomically decrement this object value and return result.
This operation should be used in multithreaded environments in order to prevent situations when multiple threads would fail to change the same value in a consistent way.
|
inline |
Atomically decrement this object value and return previous value.
This operation should be used in multithreaded environments in order to prevent situations when multiple threads would fail to change the same value in a consistent way.
|
inline |
Assignment operator that takes integer value.
When many threads attempt to change interlocked value at the same time, any one can be the last, and the result value will be atomically changed.
value | Value of interlocked variable |
|
inline |
Object assignment operator.
If during this operation the value of the other object keeps changing, the result value will be consistent, correspond to some value that was held by the other object at an unknown time of the copy operation. If during this operation the value of this object keeps changing with other assignment operators, the result of the copy can be discarded, however if increment or decrement operations are used, the increments will start to work on the new value.
other | Interlocked object from which to copy value |