logog
logger optimized for games
Multithread locking and mutexes

The Mutex object is responsible for multithread safety in logog. All platforms support a Mutex object. Only one thread may acquire a Mutex object at one time. Other threads fall into a wait state until the locking thread releases the Mutex.

The ScopedLock object is a convenient way to represent a Mutex lock as part of an object's auto scope. To use a ScopedLock, create a Mutex lock on a known thread, then create a ScopedLock with the previously defined Lock as a parameter. Code is guaranteed to be single threaded within the scope of the ScopedLock.

{
{
LOGOG_COUT << _LG("Lock is on") << endl;
}
{
logog::ScopedLock s1( *pM );
LOGOG_COUT << _LG("Lock is on") << endl;
}
delete pM;
LOGOG_COUT << _LG("Lock unlocked") << endl;
}
return 0;