34 #ifndef _QORE_QORERWLOCK_H
35 #define _QORE_QORERWLOCK_H
61 pthread_rwlock_init(&
m, 0);
70 pthread_rwlock_destroy(&
m);
76 return pthread_rwlock_wrlock(&
m);
81 return pthread_rwlock_trywrlock(&
m);
86 return pthread_rwlock_unlock(&
m);
91 return pthread_rwlock_rdlock(&
m);
96 return pthread_rwlock_tryrdlock(&
m);
111 DLLLOCAL QoreAutoRWReadLocker& operator=(
const QoreAutoRWReadLocker&);
114 DLLLOCAL
void *
operator new(size_t);
148 DLLLOCAL QoreAutoRWWriteLocker& operator=(
const QoreAutoRWWriteLocker&);
151 DLLLOCAL
void *
operator new(size_t);
185 DLLLOCAL QoreSafeRWReadLocker& operator=(
const QoreSafeRWReadLocker&);
188 DLLLOCAL
void *
operator new(size_t);
248 DLLLOCAL QoreSafeRWWriteLocker& operator=(
const QoreSafeRWWriteLocker&);
251 DLLLOCAL
void *
operator new(size_t);
300 class QoreOptionalRWWriteLocker {
305 DLLLOCAL QoreOptionalRWWriteLocker(
QoreRWLock* n_l) : l(n_l->trywrlock() ? 0 : n_l) {
308 DLLLOCAL QoreOptionalRWWriteLocker(
QoreRWLock& n_l) : l(n_l.trywrlock() ? 0 : &n_l) {
311 DLLLOCAL ~QoreOptionalRWWriteLocker() {
316 DLLLOCAL
operator bool()
const {
321 class QoreOptionalRWReadLocker {
326 DLLLOCAL QoreOptionalRWReadLocker(
QoreRWLock* n_l) : l(n_l->tryrdlock() ? 0 : n_l) {
329 DLLLOCAL QoreOptionalRWReadLocker(
QoreRWLock& n_l) : l(n_l.tryrdlock() ? 0 : &n_l) {
332 DLLLOCAL ~QoreOptionalRWReadLocker() {
337 DLLLOCAL
operator bool()
const {
342 class qore_var_rwlock_priv;
344 class QoreVarRWLock {
347 DLLLOCAL QoreVarRWLock(
const QoreVarRWLock&);
349 DLLLOCAL QoreVarRWLock& operator=(
const QoreVarRWLock&);
352 qore_var_rwlock_priv* priv;
354 DLLLOCAL QoreVarRWLock(qore_var_rwlock_priv* p);
357 DLLLOCAL QoreVarRWLock();
360 DLLLOCAL ~QoreVarRWLock();
363 DLLLOCAL
void wrlock();
366 DLLLOCAL
int trywrlock();
369 DLLLOCAL
void unlock();
372 DLLLOCAL
void rdlock();
375 DLLLOCAL
int tryrdlock();
provides a safe and exception-safe way to hold write locks in Qore, only to be used on the stack...
Definition: QoreRWLock.h:142
DLLLOCAL QoreAutoRWWriteLocker(QoreRWLock &n_l)
creates the object and grabs the write lock
Definition: QoreRWLock.h:159
DLLLOCAL int wrlock()
grabs the write lock
Definition: QoreRWLock.h:75
DLLLOCAL QoreSafeRWWriteLocker(QoreRWLock &n_l)
creates the object and grabs the write lock
Definition: QoreRWLock.h:262
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition: QoreRWLock.h:224
DLLEXPORT int gettid()
returns the current TID number
DLLLOCAL ~QoreSafeRWReadLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:211
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition: QoreRWLock.h:287
DLLLOCAL QoreSafeRWReadLocker(QoreRWLock *n_l)
creates the object and grabs the read lock
Definition: QoreRWLock.h:205
DLLLOCAL QoreRWLock()
creates and initializes the lock
Definition: QoreRWLock.h:57
DLLLOCAL ~QoreRWLock()
destroys the lock
Definition: QoreRWLock.h:66
DLLLOCAL ~QoreAutoRWReadLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:132
DLLLOCAL ~QoreAutoRWWriteLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:169
bool locked
lock flag
Definition: QoreRWLock.h:258
bool locked
lock flag
Definition: QoreRWLock.h:195
DLLLOCAL QoreSafeRWReadLocker(QoreRWLock &n_l)
creates the object and grabs the read lock
Definition: QoreRWLock.h:199
provides a safe and exception-safe way to hold write locks in Qore, only to be used on the stack...
Definition: QoreRWLock.h:242
DLLLOCAL int unlock()
unlocks the lock (assumes the lock is locked)
Definition: QoreRWLock.h:85
DLLLOCAL int rdlock()
grabs the read lock
Definition: QoreRWLock.h:90
provides a safe and exception-safe way to hold read locks in Qore, only to be used on the stack...
Definition: QoreRWLock.h:105
DLLLOCAL QoreAutoRWReadLocker(QoreRWLock &n_l)
creates the object and grabs the read lock
Definition: QoreRWLock.h:122
provides a safe and exception-safe way to hold read locks in Qore, only to be used on the stack...
Definition: QoreRWLock.h:179
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:155
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held ...
Definition: QoreRWLock.h:217
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:118
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: QoreRWLock.h:231
provides a simple POSIX-threads-based read-write lock
Definition: QoreRWLock.h:47
DLLLOCAL QoreSafeRWWriteLocker(QoreRWLock *n_l)
creates the object and grabs the write lock
Definition: QoreRWLock.h:268
pthread_rwlock_t m
the actual locking primitive wrapped in this class
Definition: QoreRWLock.h:50
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: QoreRWLock.h:294
DLLLOCAL QoreAutoRWReadLocker(QoreRWLock *n_l)
creates the object and grabs the read lock
Definition: QoreRWLock.h:127
DLLLOCAL int tryrdlock()
tries to grab the read lock; does not block if unsuccessful; returns 0 if successful ...
Definition: QoreRWLock.h:95
DLLLOCAL QoreRWLock & operator=(const QoreRWLock &)
this function is not implemented; it is here as a private function in order to prohibit it from being...
DLLLOCAL QoreAutoRWWriteLocker(QoreRWLock *n_l)
creates the object and grabs the write lock
Definition: QoreRWLock.h:164
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:255
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:192
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held ...
Definition: QoreRWLock.h:280
DLLLOCAL int trywrlock()
tries to grab the write lock; does not block if unsuccessful; returns 0 if successful ...
Definition: QoreRWLock.h:80
DLLLOCAL ~QoreSafeRWWriteLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:274