![]() |
VR-Link API Documentation for HLA Evolved
|
DtScopedLock provides a Boost source compatible scoped lock for DtMutex. More...
Collaboration diagram for DtScopedLock:Public Member Functions | |
| DtScopedLock (DtMutex &mx, bool initially_locked=true) | |
| Constructs a DtScopedLock on a mutex and conditionally locks that mutex. | |
| ~DtScopedLock () | |
| Destructor, which will unlock if the mutex was locked. | |
| void | lock () |
| Lock the mutex. | |
| void | unlock () |
| Unlock the mutex. | |
| bool | locked () const |
| operator const void * () const | |
| else null pointer. | |
Protected Attributes | |
| DtMutex & | myMutex |
| bool | myLockedState |
Private Member Functions | |
| DtScopedLock (const DtScopedLock &) | |
| Ensures non-copiable. | |
| DtScopedLock & | operator= (const DtScopedLock &) |
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) { DtScopedLock lock(io_mutex); printf(string); }
| DtScopedLock::DtScopedLock | ( | DtMutex & | mx, |
| bool | initially_locked = true |
||
| ) | [explicit] |
Constructs a DtScopedLock on a mutex and conditionally locks that mutex.
Destructor, which will unlock if the mutex was locked.
| DtScopedLock::DtScopedLock | ( | const DtScopedLock & | ) | [private] |
Ensures non-copiable.
| void DtScopedLock::lock | ( | ) |
Lock the mutex.
| bool DtScopedLock::locked | ( | ) | const |
| true | The mutex is locked. |
| false | The mutex is unlocked. |
| DtScopedLock::operator const void * | ( | ) | const |
else null pointer.
| DtScopedLock& DtScopedLock::operator= | ( | const DtScopedLock & | ) | [private] |
| void DtScopedLock::unlock | ( | ) |
Unlock the mutex.
bool DtScopedLock::myLockedState [protected] |
DtMutex& DtScopedLock::myMutex [protected] |