Using a Lock Guard
To use a lock guard, declare a named instance of the guard class and initialize it with a reference to the synchronization mechanism, as shown in
Example 39.
Example 39 – Using a lock guard
RWMutexLock mutex;
{
RWTLockGuard<RWMutexLock> lock(mutex); // 1
// Mutex is acquired!
} // 2
// Mutex is released!