32 #ifndef _QORE_QORETHREADLOCK_H 34 #define _QORE_QORETHREADLOCK_H 52 pthread_mutex_t ptm_lock;
58 DLLLOCAL
void init(
const pthread_mutexattr_t* pma = 0) {
62 pthread_mutex_init(&ptm_lock, pma);
79 pthread_mutex_destroy(&ptm_lock);
94 pthread_mutex_lock(&ptm_lock);
105 pthread_mutex_unlock(&ptm_lock);
114 return pthread_mutex_trylock(&ptm_lock);
134 DLLLOCAL AutoLocker& operator=(
const AutoLocker&);
137 DLLLOCAL
void *
operator new(size_t);
158 if (!already_locked) {
167 if (!already_locked) {
173 DLLLOCAL ~AutoLocker() {
193 DLLLOCAL AutoUnlocker& operator=(
const AutoUnlocker&);
196 DLLLOCAL
void *
operator new(size_t);
215 DLLLOCAL ~AutoUnlocker() {
236 DLLLOCAL SafeLocker& operator=(
const SafeLocker&);
239 DLLLOCAL
void *
operator new(size_t);
262 DLLLOCAL ~SafeLocker() {
282 DLLLOCAL
void stay_locked() {
288 DLLLOCAL
void relock() {
306 DLLLOCAL OptLocker& operator=(
const OptLocker&);
309 DLLLOCAL
void *
operator new(size_t);
323 DLLLOCAL ~OptLocker() {
329 #endif // _QORE_QORETHREADLOCK_H DLLLOCAL ~QoreThreadLock()
destroys the lock
Definition: QoreThreadLock.h:78
DLLLOCAL int trylock()
attempts to acquire the mutex and returns the status immediately; does not block
Definition: QoreThreadLock.h:113
a thread condition class implementing a wrapper for pthread_cond_t
Definition: QoreCondition.h:45
provides a safe and exception-safe way to hold locks in Qore, only to be used on the stack...
Definition: QoreThreadLock.h:128
provides a safe and exception-safe way to hold optional locks in Qore, only to be used on the stack...
Definition: QoreThreadLock.h:300
DLLLOCAL void lock()
grabs the lock (assumes that the lock is unlocked)
Definition: QoreThreadLock.h:90
QoreThreadLock * lck
the pointer to the lock that will be managed
Definition: QoreThreadLock.h:141
DLLLOCAL void unlock()
releases the lock (assumes that the lock is locked)
Definition: QoreThreadLock.h:101
QoreThreadLock * lck
the pointer to the lock that will be managed
Definition: QoreThreadLock.h:200
bool locked
flag indicating if the lock is held or not
Definition: QoreThreadLock.h:246
provides a mutually-exclusive thread lock
Definition: QoreThreadLock.h:47
QoreThreadLock * lck
the pointer to the lock that will be managed
Definition: QoreThreadLock.h:313
DLLLOCAL QoreThreadLock()
creates the lock
Definition: QoreThreadLock.h:68
QoreThreadLock * lck
the pointer to the lock that will be managed
Definition: QoreThreadLock.h:243
provides an exception-safe way to manage locks in Qore, only to be used on the stack, cannot be dynamically allocated
Definition: QoreThreadLock.h:230
provides a safe and exception-safe way to release and re-acquire locks in Qore, only to be used on th...
Definition: QoreThreadLock.h:187