CXScopeLockReadWrite

From cxwiki

The CXScopeLockReadWrite class is intended to be constructed on the stack as a mechanism to take a lock and ensure that it is released again when the CXScopeLockReadWrite object goes out of scope. This is intended as a way to reduce manual lock management errors. This class is the direct equivalent of CXScopeLock for CXReadWriteLocks.
 
// Construct a CXScopeLockReadWrite object, taking a lock on the specified mutex.
CXScopeLockReadWrite(const CXReadWriteLock& mutex, CXReadWriteLock::ShareTypeEnum shareType);

// Construct a CXScopeLockReadWrite object, optionally taking a lock on the specified mutex.
CXScopeLockReadWrite(const CXReadWriteLock& mutex, CXReadWriteLock::ShareTypeEnum shareType, bool bShouldTakeLock);

// Destruct a CXScopeLockReadWrite object, releasing any outstanding lock held by this 
// object.
~CXScopeLockReadWrite(void);

// Take a lock on the specified mutex. This is a no-op if the specified mutex is 
// already locked. This results in any outstanding mutex lock held by this object
// being releasing first.
void Lock(const CXReadWriteLock& mutex, CXReadWriteLock::ShareTypeEnum shareType);

// Unlock any outstanding lock held by this object.
void Unlock(void);

// Detach from any outstanding locks without releasing them. It is the 
// responsibility of the caller to determine whether anything was locked and
// release that lock when necessary.
void Detach(void);