CSingleLock::CSingleLock
CSingleLock オブジェクトを構築します。
explicit CSingleLock(
CSyncObject* pObject,
BOOL bInitialLock = FALSE
);
パラメーター
pObject
同期へのポインターにアクセスするためについて説明します。nullにすることはできません。bInitialLock
最初に指定されたオブジェクトにアクセスしようとするかどうかを指定します。
解説
この関数は、被制御リソースのアクセスのメンバー関数から一般に、内から呼び出されます。
使用例
// m_CritSection is a data member (of type CCriticalSection)
// of an existing class that implements the resource being shared.
// Relate the synchronization object (m_CritSection) with
// our CSingleLock object.
CSingleLock singleLock(&m_CritSection);
singleLock.Lock(); // Attempt to lock the shared resource
if (singleLock.IsLocked()) // Resource has been locked
{
//...use the shared resource...
// Now that we are finished,
// unlock the resource for others.
singleLock.Unlock();
}
必要条件
Header: afxmt.h