Thea
|
An integer that may safely be used on different threads without external locking. More...
#include <AtomicInt32.hpp>
Public Member Functions | |
int32 | add (int32 const x) |
Increment by x and return the old value, before the addition. More... | |
AtomicInt32 () | |
Initial value is undefined. More... | |
AtomicInt32 (int32 x) | |
Atomic initialization. More... | |
AtomicInt32 (AtomicInt32 const &x) | |
Atomic copy constructor. More... | |
int32 | compareAndSet (int32 comperand, int32 exchange) |
Atomic test-and-set: if *this == comperand then *this := exchange , else do nothing. More... | |
int32 | decrement () |
Decrement by 1. More... | |
void | increment () |
Increment by 1. More... | |
AtomicInt32 const & | operator= (int32 x) |
Atomic set. More... | |
void | operator= (AtomicInt32 const &x) |
Atomic set. More... | |
int32 | sub (int32 const x) |
Decrement by x and return the old value, before the subtraction. More... | |
int32 | value () const |
Get the current value. More... | |
An integer that may safely be used on different threads without external locking.
On Win32, Linux, FreeBSD, and Mac OS X this is implemented without locks. Derived from the G3D library: http://g3d.sourceforge.net
Definition at line 44 of file AtomicInt32.hpp.
AtomicInt32 | ( | ) |
Initial value is undefined.
Definition at line 60 of file AtomicInt32.hpp.
|
explicit |
Atomic initialization.
Definition at line 63 of file AtomicInt32.hpp.
AtomicInt32 | ( | AtomicInt32 const & | x | ) |
Atomic copy constructor.
Definition at line 69 of file AtomicInt32.hpp.
int32 add | ( | int32 const | x | ) |
Increment by x and return the old value, before the addition.
Definition at line 94 of file AtomicInt32.hpp.
int32 compareAndSet | ( | int32 | comperand, |
int32 | exchange | ||
) |
Atomic test-and-set: if *this == comperand
then *this := exchange
, else do nothing.
In both cases, returns the old value of *this
.
Performs an atomic comparison of the integer with the comperand value. If this is equal to the comperand, the exchange value is stored in this. Otherwise, no operation is performed.
Definition at line 174 of file AtomicInt32.hpp.
int32 decrement | ( | ) |
Decrement by 1.
Definition at line 143 of file AtomicInt32.hpp.
void increment | ( | ) |
Increment by 1.
Definition at line 122 of file AtomicInt32.hpp.
AtomicInt32 const& operator= | ( | int32 | x | ) |
Atomic set.
Definition at line 75 of file AtomicInt32.hpp.
void operator= | ( | AtomicInt32 const & | x | ) |
Atomic set.
Definition at line 82 of file AtomicInt32.hpp.
int32 sub | ( | int32 const | x | ) |
Decrement by x and return the old value, before the subtraction.
Definition at line 116 of file AtomicInt32.hpp.
int32 value | ( | ) | const |
Get the current value.
Definition at line 88 of file AtomicInt32.hpp.