Releasing and Reacquiring a Guarded Lock

To release and reacquire a guarded lock, you should use the release() and acquire() members of the guard object. as shown in Releasing and reacquiring a guarded lock. These member functions update the internal state of the guard so that the destructor does not attempt to release a lock that is no longer held.

Example 111. Releasing and reacquiring a guarded lock

{

RWTLockGuard<RWMutexLock> lock(mutex);

// Mutex is acquired!

lock.release();

// Mutex is released!

lock.acquire();

// Mutex is acquired!

}

// Mutex is released!