DtScopedLock provides a Boost source compatible scoped lock for DtMutex.
More...
Detailed Description
DtScopedLock provides a Boost source compatible scoped lock for DtMutex.
A DtScopedLock is a safe locking pattern for use in multi-threaded applications. DtScopedLock is non-copiable object, which should be created on the stack. The lock ensures that upon deallocation the lock is released.
DtMutex io_mutex;
void threadSafe_printf(const char* string)
{
printf(string);
}
Constructor & Destructor Documentation
| DtScopedLock::DtScopedLock |
( |
DtMutex & |
mx, |
|
|
bool |
initially_locked = true |
|
) |
| |
|
explicit |
Constructs a DtScopedLock on a mutex and conditionally locks that mutex.
| DtScopedLock::~DtScopedLock |
( |
| ) |
|
Destructor, which will unlock if the mutex was locked.
Member Function Documentation
| void DtScopedLock::lock |
( |
| ) |
|
| bool DtScopedLock::locked |
( |
| ) |
const |
- Returns
- The locked state of the mutex.
- Return values
-
| true | The mutex is locked. |
| false | The mutex is unlocked. |
| DtScopedLock::operator const void * |
( |
| ) |
const |
| void DtScopedLock::unlock |
( |
| ) |
|
Member Data Documentation
| bool DtScopedLock::myLockedState |
|
protected |
The documentation for this class was generated from the following file: