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);
114 DLLLOCAL
void *
operator new(size_t);
153 DLLLOCAL
void *
operator new(size_t);
192 DLLLOCAL
void *
operator new(size_t);
255 DLLLOCAL
void *
operator new(size_t);
304 class QoreOptionalRWWriteLocker {
309 DLLLOCAL QoreOptionalRWWriteLocker(
QoreRWLock* n_l) : l(n_l->trywrlock() ? 0 : n_l) {
312 DLLLOCAL QoreOptionalRWWriteLocker(
QoreRWLock& n_l) : l(n_l.trywrlock() ? 0 : &n_l) {
315 DLLLOCAL ~QoreOptionalRWWriteLocker() {
320 DLLLOCAL
operator bool()
const {
325 class QoreOptionalRWReadLocker {
330 DLLLOCAL QoreOptionalRWReadLocker(
QoreRWLock* n_l) : l(n_l->tryrdlock() ? 0 : n_l) {
333 DLLLOCAL QoreOptionalRWReadLocker(
QoreRWLock& n_l) : l(n_l.tryrdlock() ? 0 : &n_l) {
336 DLLLOCAL ~QoreOptionalRWReadLocker() {
341 DLLLOCAL
operator bool()
const {
346 class qore_var_rwlock_priv;
348 class QoreVarRWLock {
351 DLLLOCAL QoreVarRWLock(
const QoreVarRWLock&);
353 DLLLOCAL QoreVarRWLock& operator=(
const QoreVarRWLock&);
356 qore_var_rwlock_priv* priv;
358 DLLLOCAL QoreVarRWLock(qore_var_rwlock_priv* p);
361 DLLLOCAL QoreVarRWLock();
364 DLLLOCAL ~QoreVarRWLock();
367 DLLLOCAL
void wrlock();
370 DLLLOCAL
int trywrlock();
373 DLLLOCAL
void unlock();
376 DLLLOCAL
void rdlock();
379 DLLLOCAL
int tryrdlock();
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()
destroys the object and releases the lock
Definition: QoreRWLock.h:133
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:118
provides a safe and exception-safe way to hold write locks in Qore, only to be used on the stack,...
Definition: QoreRWLock.h:144
DLLLOCAL ~QoreAutoRWWriteLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:172
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:157
provides a simple POSIX-threads-based read-write lock
Definition: QoreRWLock.h:47
pthread_rwlock_t m
the actual locking primitive wrapped in this class
Definition: QoreRWLock.h:50
DLLLOCAL ~QoreRWLock()
destroys the lock
Definition: QoreRWLock.h:66
DLLLOCAL int wrlock()
grabs the write lock
Definition: QoreRWLock.h:75
DLLLOCAL QoreRWLock()
creates and initializes the lock
Definition: QoreRWLock.h:57
DLLLOCAL int trywrlock()
tries to grab the write lock; does not block if unsuccessful; returns 0 if successful
Definition: QoreRWLock.h:80
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
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 int tryrdlock()
tries to grab the read lock; does not block if unsuccessful; returns 0 if successful
Definition: QoreRWLock.h:95
provides a safe and exception-safe way to hold read locks in Qore, only to be used on the stack,...
Definition: QoreRWLock.h:183
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition: QoreRWLock.h:228
bool locked
lock flag
Definition: QoreRWLock.h:199
DLLLOCAL ~QoreSafeRWReadLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:215
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held
Definition: QoreRWLock.h:221
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:196
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:235
provides a safe and exception-safe way to hold write locks in Qore, only to be used on the stack,...
Definition: QoreRWLock.h:246
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition: QoreRWLock.h:291
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:259
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held
Definition: QoreRWLock.h:284
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:298
DLLLOCAL ~QoreSafeRWWriteLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:278
bool locked
lock flag
Definition: QoreRWLock.h:262
DLLEXPORT int q_gettid() noexcept
returns the current TID number