Microsoft DirectX 8.0 |
Provides a thread lock.
Declaration: Wxutil.h
This class is a wrapper for a critical section. You can lock and unlock the thread by calling the Lock and Unlock methods. However, it is safer to use this class in conjunction with the CAutoLock class. When the CAutoLock class goes out of scope, it automatically unlocks the CCritSec object. Moreover, it compiles to efficient inline code.
Public Member Variables | |
---|---|
m_currentOwner | Thread identifier of the owning thread. |
m_lockCount | Number of outstanding locks on this object. |
m_fTrace | Boolean value that specifies whether to trace this lock. |
Public Methods | |
CCritSec | Constructor method. |
~CCritSec | Destructor method. |
Lock | Locks the critical section object. |
Unlock | Unlocks the critical section object. |
Thread identifier of the owning thread.
Syntax
DWORD m_currentOwner;
Remarks
This member variable is defined only in the debug version of the base class. The CCritSec debug functions use this member.
Number of outstanding locks on this object.
Syntax
DWORD m_lockCount;
Remarks
This member variable is defined only in the debug version of the base class. The CCritSec debug functions use this member.
Boolean value that specifies whether to trace this lock.
Syntax
BOOL m_fTrace;
Remarks
This member variable is defined only in the debug version of the base class. If the value is TRUE, a trace of the lock state is written to the debug log. (Debug logging for critical sections must be active.) For more information, see DbgLockTrace.
Constructor method.
Syntax
CCritSec(void);
Remarks
This method calls the Microsoft® Win32® InitializeCriticalSection function to initialize the critical section.
Destructor method.
Syntax
~CCritSec(void);
Remarks
This method calls the Microsoft® Win32® DeleteCriticalSection function to delete the critical section.
Locks the critical section object.
Syntax
void Lock(void);
Return Value
No return value.
Remarks
This method calls the Microsoft® Win32® EnterCriticalSection method.
Call the CCritSec::Unlock member function to unlock the critical section. You can make multiple calls to the Lock method on the same thread; be sure to call Unlock a corresponding number of times.
If the object is already locked by another thread, the CCritSec::Lock method blocks until the object is released, or until a possible-deadlock exception occurs.
Unlocks the critical section object.
Syntax
void Unlock(void);
Return Value
No return value.
Remarks
This method calls the Microsoft® Win32® LeaveCriticalSection method.
Call this method once for each call to the Lock method.