24 #ifndef _QORE_QORETHREADLOCK_H
26 #define _QORE_QORETHREADLOCK_H
46 pthread_mutex_t ptm_lock;
52 DLLLOCAL
void init(
const pthread_mutexattr_t *pma = 0) {
56 pthread_mutex_init(&ptm_lock, pma);
74 pthread_mutex_destroy(&ptm_lock);
89 pthread_mutex_lock(&ptm_lock);
100 pthread_mutex_unlock(&ptm_lock);
109 return pthread_mutex_trylock(&ptm_lock);
129 DLLLOCAL AutoLocker& operator=(
const AutoLocker&);
132 DLLLOCAL
void *
operator new(size_t);
170 DLLLOCAL AutoUnlocker& operator=(
const AutoUnlocker&);
173 DLLLOCAL
void *
operator new(size_t);
214 DLLLOCAL SafeLocker& operator=(
const SafeLocker&);
217 DLLLOCAL
void *
operator new(size_t);
277 DLLLOCAL OptLocker& operator=(
const OptLocker&);
280 DLLLOCAL
void *
operator new(size_t);
300 #endif // _QORE_QORETHREADLOCK_H
DLLLOCAL ~QoreThreadLock()
destroys the lock
Definition: QoreThreadLock.h:73
DLLLOCAL ~AutoUnlocker()
grabs the lock and destroys the object
Definition: QoreThreadLock.h:192
DLLLOCAL ~AutoLocker()
destroys the object and releases the lock
Definition: QoreThreadLock.h:150
DLLLOCAL AutoLocker(QoreThreadLock *l)
creates the object and grabs the lock
Definition: QoreThreadLock.h:140
DLLLOCAL void stay_locked()
will not unlock the lock when the destructor is run; do not use any other functions of this class aft...
Definition: QoreThreadLock.h:260
DLLLOCAL QoreThreadLock(const pthread_mutexattr_t *ma)
creates the lock with the given attributes
Definition: QoreThreadLock.h:68
DLLLOCAL QoreThreadLock(const QoreThreadLock &)
creates a new object (not based on the original lock status)
Definition: QoreThreadLock.h:78
DLLLOCAL AutoUnlocker(QoreThreadLock *l)
creates the object and releases the lock
Definition: QoreThreadLock.h:181
DLLLOCAL SafeLocker(QoreThreadLock &l)
creates the object and grabs the lock
Definition: QoreThreadLock.h:234
DLLLOCAL int trylock()
attempts to acquire the mutex and returns the status immediately; does not block
Definition: QoreThreadLock.h:108
DLLLOCAL AutoLocker(QoreThreadLock &l)
creates the object and grabs the lock
Definition: QoreThreadLock.h:145
a thread condition class implementing a wrapper for pthread_cond_t
Definition: QoreCondition.h:37
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition: QoreThreadLock.h:253
provides a safe and exception-safe way to hold locks in Qore, only to be used on the stack...
Definition: QoreThreadLock.h:123
provides a safe and exception-safe way to hold optional locks in Qore, only to be used on the stack...
Definition: QoreThreadLock.h:271
DLLLOCAL void lock()
grabs the lock (assumes that the lock is unlocked)
Definition: QoreThreadLock.h:85
QoreThreadLock * lck
the pointer to the lock that will be managed
Definition: QoreThreadLock.h:136
DLLLOCAL void unlock()
releases the lock (assumes that the lock is locked)
Definition: QoreThreadLock.h:96
DLLLOCAL AutoUnlocker(QoreThreadLock &l)
creates the object and releases the lock
Definition: QoreThreadLock.h:187
QoreThreadLock * lck
the pointer to the lock that will be managed
Definition: QoreThreadLock.h:177
DLLLOCAL OptLocker(QoreThreadLock *l)
creates the object and grabs the lock if the argument is not NULL
Definition: QoreThreadLock.h:288
DLLLOCAL ~SafeLocker()
destroys the object and unlocks the lock if it's held
Definition: QoreThreadLock.h:240
bool locked
flag indicating if the lock is held or not
Definition: QoreThreadLock.h:224
provides a mutually-exclusive thread lock
Definition: QoreThreadLock.h:41
DLLLOCAL SafeLocker(QoreThreadLock *l)
creates the object and grabs the lock
Definition: QoreThreadLock.h:228
QoreThreadLock * lck
the pointer to the lock that will be managed
Definition: QoreThreadLock.h:284
DLLLOCAL QoreThreadLock()
creates the lock
Definition: QoreThreadLock.h:63
QoreThreadLock * lck
the pointer to the lock that will be managed
Definition: QoreThreadLock.h:221
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held ...
Definition: QoreThreadLock.h:246
provides an exception-safe way to manage locks in Qore, only to be used on the stack, cannot be dynamically allocated
Definition: QoreThreadLock.h:208
provides a safe and exception-safe way to release and re-acquire locks in Qore, only to be used on th...
Definition: QoreThreadLock.h:164
DLLLOCAL ~OptLocker()
releases the lock if there is a lock pointer being managed and destroys the object ...
Definition: QoreThreadLock.h:294