SafeLocker Class Reference

provides an exception-safe way to manage locks in Qore, only to be used on the stack, cannot be dynamically allocated More...

#include <QoreThreadLock.h>

List of all members.

Public Member Functions

DLLEXPORT SafeLocker (QoreThreadLock *l)
 creates the object and grabs the lock
DLLEXPORT SafeLocker (QoreThreadLock &l)
 creates the object and grabs the lock
DLLEXPORT ~SafeLocker ()
 destroys the object and unlocks the lock if it's held
DLLEXPORT void lock ()
 locks the object and updates the locked flag, assumes that the lock is not already held
DLLEXPORT void unlock ()
 unlocks the object and updates the locked flag, assumes that the lock is held
DLLEXPORT void stay_locked ()
 will not unlock the lock when the destructor is run; do not use any other functions of this class after calling this function

Protected Attributes

QoreThreadLocklck
 the pointer to the lock that will be managed
bool locked
 flag indicating if the lock is held or not


Detailed Description

provides an exception-safe way to manage locks in Qore, only to be used on the stack, cannot be dynamically allocated

Ensures that locks are released by locking the lock when the object is created and releasing it when the object is destroyed. Also allows the lock to be released before the object's destruction at the expense of one extra byte on the stack compared to the AutoLocker class.

See also:
AutoLocker

The documentation for this class was generated from the following file:

Generated on Mon Oct 26 09:09:50 2009 for Qore Programming Language by  doxygen 1.5.6