Microsoft DirectX 8.0

CAutoLock Class

Holds a critical section for the scope of a block.

Declaration: Wxutil.h

This class works in conjunction with the CCritSec class, which is a wrapper for critical section objects. The CAutoLock constructor locks the critical section, and the destructor unlocks it. By using a CAutoLock object as a local variable, you can lock a critical section with the guarantee that all code paths will unlock the critical section.

The following code example shows how to use this class:

CCritSec csMyLock;  // Critical section is not locked yet.

{
    CAutoLock cObjectLock(&csMyLock);  // Lock the critical section.

    // Protected section of code.     

} // Lock goes out of scope here.

The methods in this class are not designed to be overridden.

Protected Member Variables
m_pLockCritical section for this lock.
Public Methods
CAutoLockConstructor method. Locks the specified critical section object.
~CAutoLockDestructor method. Unlocks the critical section object.

CAutoLock.m_pLock

CAutoLock Class

Critical section for this lock.

Syntax

CCritSec *m_pLock;

CAutoLock::CAutoLock

CAutoLock Class

Constructor method. Locks the specified critical section object.

Syntax

CAutoLock(
    CCritSec *plock
);

Parameters

plock
Pointer to a CCritSec object, which contains a critical section object.

CAutoLock::~CAutoLock

CAutoLock Class

Destructor method. Unlocks the critical section object.

Syntax

CAutoLock(void);