Thread synchronization primitives
|
|
void AssertST()
This operation only has effect in DEBUG mode. If any Thread was started prior to calling AssertST, it will stop the execution with diagnostic message. The purpose is that some global initialization routines are best performed before any multi-threading starts. AssertST can be used to assure this as runtime check.
typedef integer_type Atomic
This is the integer type that can be used as argument of AtomicInc/AtomicDec function. It is compatible with 'int' - it has the same value range and it can be converted to 'int'. Since C++11, it is in fact implemented using std::atomic<int> and kept only because of backward compatibility.
int AtomicInc(volatile Atomic& t)
Increments t by one and returns the result ("++t").
int AtomicDec(volatile Atomic& t)
Decrements t by one and returns the result ("--t").
INTERLOCKED
This macro adds static Mutex to the block. For example:
INTERLOCKED {
Foo();
}
is equivalent to
{ static Mutex uniquename;
uniquename.Enter();
Foo();
uniquename.Leave();
}
INTERLOCKED_(cs)
Similar to INTERLOCKED, but instead of 'anonymous' implicit static Mutex it uses explicit Mutex cs.
ONCELOCK
Designates block that only gets performed at first run, taking into account all multi-threading issues. In single threaded environment
ONCELOCK { Foo(); }
is equivalent to
{ static bool x; if(!x) { x = true; Foo(); } }.
ONCELOCK_(o_b_)
Similar to oncelock, but allows associating a flag variable, which must be of type OnceFlag. Such variable has to initialized to zero (preferably by static zero initialization of memory). On the first run of for specific OnceFlag, ONCELOCK_ performs the block (and changes the variable so that it is not performed on the next run).
|