Using the Unlock Guard Class
The same result can be achieved by using an RWTUnlockGuard to temporarily release then reacquire a synchronization resource, as shown in Figure 41. The unlock guard class works in the same way as the lock guard class, except that it releases the resource in the constructor, and reacquires it in the destructor.
Example 41 – Using an unlock guard
{
RWTLockGuard<RWMutexLock> lock(mutex);
// Mutex is acquired!
{
RWTUnlockGuard<RWMutexLock> unlock(mutex);
// Mutex is released!
}
// Mutex is acquired!
}
// Mutex is released!