ASL
|
Atomic version of another type.
This adds some space and overhead, use with care.
Variable value
can be read or written from different threads without interfering.
Basic operators of the underlying type are exposed (++, +=, -=, *=, /=, ==, <<, ...). If the underlying type is a class you can call methods using opertor ->
, and those calls will be syncronized.
For other operations you can cast to the underlying type or use operator ~
. Or you can use operator *
to get a reference to the internal variable (with no synchronization). In that case you can use the objet's mutex to protect access:
#include <Mutex.h>
Public Member Functions | |
T & | operator* () |
Returns a reference to the internal value (not synchronized) | |
Mutex & | mutex () |
Returns the internal mutex for synchronization. | |
T | operator~ () const |
Returns the value of this variable as a copy. | |
operator T () const | |
Returns the value of this variable as a copy. | |
Locked< T > | locked () |
Returns a locked wrapper for short time use. | |
Locked< T > | operator-> () |
Allows calling member functions of the internal object. | |