XLL+ Class Library (6.3)

CXlLock Class

An object which applies a lock to a CXlLockable and whose lifetime controls the duration of the lock.

class CXlLock

Overview

The CXlLock class can be used to lock an object for thread-safe access.

The most convenient way to lock a CXlLockable object is by creating a CXlLock object. CXlLock calls CXlLockable::Lock() when it is constructed, and calls CXlLockable::Unlock() when it is destroyed.

A typical usage is shown below.

CopyC++
CXlLockable sharedObject;
void UseSharedObject()
{
    CXlLock lock(sharedObject, true);
    // Do something with the sharedObject 
    // On exit from this function, the CXlLock instance will 
    // be destroyed, and sharedObject will be unlocked
}

Requirements

Header: xlpshared.h

See Also

CXlLock Methods | xlpshared.h | Ensuring global data is thread-safe | CXlLockable