32 #ifndef _QORE_QORETHREADLOCK_H
34 #define _QORE_QORETHREADLOCK_H
54 pthread_mutex_t ptm_lock;
60 DLLLOCAL
void init(
const pthread_mutexattr_t *pma = 0) {
64 pthread_mutex_init(&ptm_lock, pma);
82 pthread_mutex_destroy(&ptm_lock);
97 pthread_mutex_lock(&ptm_lock);
108 pthread_mutex_unlock(&ptm_lock);
117 return pthread_mutex_trylock(&ptm_lock);
137 DLLLOCAL AutoLocker& operator=(
const AutoLocker&);
140 DLLLOCAL
void *
operator new(size_t);
178 DLLLOCAL AutoUnlocker& operator=(
const AutoUnlocker&);
181 DLLLOCAL
void *
operator new(size_t);
222 DLLLOCAL SafeLocker& operator=(
const SafeLocker&);
225 DLLLOCAL
void *
operator new(size_t);
285 DLLLOCAL OptLocker& operator=(
const OptLocker&);
288 DLLLOCAL
void *
operator new(size_t);
308 #endif // _QORE_QORETHREADLOCK_H
DLLLOCAL ~QoreThreadLock()
destroys the lock
Definition: QoreThreadLock.h:81
DLLLOCAL ~AutoUnlocker()
grabs the lock and destroys the object
Definition: QoreThreadLock.h:200
DLLLOCAL ~AutoLocker()
destroys the object and releases the lock
Definition: QoreThreadLock.h:158
DLLLOCAL AutoLocker(QoreThreadLock *l)
creates the object and grabs the lock
Definition: QoreThreadLock.h:148
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:268
DLLLOCAL QoreThreadLock(const pthread_mutexattr_t *ma)
creates the lock with the given attributes
Definition: QoreThreadLock.h:76
DLLLOCAL QoreThreadLock(const QoreThreadLock &)
creates a new object (not based on the original lock status)
Definition: QoreThreadLock.h:86
DLLLOCAL AutoUnlocker(QoreThreadLock *l)
creates the object and releases the lock
Definition: QoreThreadLock.h:189
DLLLOCAL SafeLocker(QoreThreadLock &l)
creates the object and grabs the lock
Definition: QoreThreadLock.h:242
DLLLOCAL int trylock()
attempts to acquire the mutex and returns the status immediately; does not block
Definition: QoreThreadLock.h:116
DLLLOCAL AutoLocker(QoreThreadLock &l)
creates the object and grabs the lock
Definition: QoreThreadLock.h:153
a thread condition class implementing a wrapper for pthread_cond_t
Definition: QoreCondition.h:45
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition: QoreThreadLock.h:261
provides a safe and exception-safe way to hold locks in Qore, only to be used on the stack...
Definition: QoreThreadLock.h:131
provides a safe and exception-safe way to hold optional locks in Qore, only to be used on the stack...
Definition: QoreThreadLock.h:279
DLLLOCAL void lock()
grabs the lock (assumes that the lock is unlocked)
Definition: QoreThreadLock.h:93
QoreThreadLock * lck
the pointer to the lock that will be managed
Definition: QoreThreadLock.h:144
DLLLOCAL void unlock()
releases the lock (assumes that the lock is locked)
Definition: QoreThreadLock.h:104
DLLLOCAL AutoUnlocker(QoreThreadLock &l)
creates the object and releases the lock
Definition: QoreThreadLock.h:195
QoreThreadLock * lck
the pointer to the lock that will be managed
Definition: QoreThreadLock.h:185
DLLLOCAL OptLocker(QoreThreadLock *l)
creates the object and grabs the lock if the argument is not NULL
Definition: QoreThreadLock.h:296
DLLLOCAL ~SafeLocker()
destroys the object and unlocks the lock if it's held
Definition: QoreThreadLock.h:248
bool locked
flag indicating if the lock is held or not
Definition: QoreThreadLock.h:232
provides a mutually-exclusive thread lock
Definition: QoreThreadLock.h:49
DLLLOCAL SafeLocker(QoreThreadLock *l)
creates the object and grabs the lock
Definition: QoreThreadLock.h:236
QoreThreadLock * lck
the pointer to the lock that will be managed
Definition: QoreThreadLock.h:292
DLLLOCAL QoreThreadLock()
creates the lock
Definition: QoreThreadLock.h:71
QoreThreadLock * lck
the pointer to the lock that will be managed
Definition: QoreThreadLock.h:229
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held ...
Definition: QoreThreadLock.h:254
provides an exception-safe way to manage locks in Qore, only to be used on the stack, cannot be dynamically allocated
Definition: QoreThreadLock.h:216
provides a safe and exception-safe way to release and re-acquire locks in Qore, only to be used on th...
Definition: QoreThreadLock.h:172
DLLLOCAL ~OptLocker()
releases the lock if there is a lock pointer being managed and destroys the object ...
Definition: QoreThreadLock.h:302