Qore Programming Language
0.9.4.6
|
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>
Public Member Methods | |
DLLLOCAL | SafeLocker (QoreThreadLock *l) |
creates the object and grabs the lock | |
DLLLOCAL | SafeLocker (QoreThreadLock &l) |
creates the object and grabs the lock | |
DLLLOCAL | ~SafeLocker () |
destroys the object and unlocks the lock if it's held | |
DLLLOCAL void | lock () |
locks the object and updates the locked flag, assumes that the lock is not already held | |
DLLLOCAL void | relock () |
relocks an unlock lock | |
DLLLOCAL 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 | |
DLLLOCAL void | unlock () |
unlocks the object and updates the locked flag, assumes that the lock is held | |
Private Attributes | |
QoreThreadLock * | lck |
the pointer to the lock that will be managed | |
bool | locked |
flag indicating if the lock is held or not | |
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.