26 #ifndef _QORE_QORERWLOCK_H
27 #define _QORE_QORERWLOCK_H
49 pthread_rwlock_init(&
m, 0);
58 pthread_rwlock_destroy(&
m);
64 return pthread_rwlock_rdlock(&
m);
69 return pthread_rwlock_wrlock(&
m);
74 return pthread_rwlock_tryrdlock(&
m);
79 return pthread_rwlock_trywrlock(&
m);
84 return pthread_rwlock_unlock(&
m);
99 DLLLOCAL QoreAutoRWReadLocker& operator=(
const QoreAutoRWReadLocker&);
102 DLLLOCAL
void *
operator new(size_t);
136 DLLLOCAL QoreAutoRWWriteLocker& operator=(
const QoreAutoRWWriteLocker&);
139 DLLLOCAL
void *
operator new(size_t);
173 DLLLOCAL QoreSafeRWReadLocker& operator=(
const QoreSafeRWReadLocker&);
176 DLLLOCAL
void *
operator new(size_t);
236 DLLLOCAL QoreSafeRWWriteLocker& operator=(
const QoreSafeRWWriteLocker&);
239 DLLLOCAL
void *
operator new(size_t);
288 class QoreOptionalRWWriteLocker {
293 DLLLOCAL QoreOptionalRWWriteLocker(
QoreRWLock* n_l) : l(n_l->trywrlock() ? 0 : n_l) {
296 DLLLOCAL QoreOptionalRWWriteLocker(
QoreRWLock& n_l) : l(n_l.trywrlock() ? 0 : &n_l) {
299 DLLLOCAL ~QoreOptionalRWWriteLocker() {
304 DLLLOCAL
operator bool()
const {
309 class QoreOptionalRWReadLocker {
314 DLLLOCAL QoreOptionalRWReadLocker(
QoreRWLock* n_l) : l(n_l->tryrdlock() ? 0 : n_l) {
317 DLLLOCAL QoreOptionalRWReadLocker(
QoreRWLock& n_l) : l(n_l.tryrdlock() ? 0 : &n_l) {
320 DLLLOCAL ~QoreOptionalRWReadLocker() {
325 DLLLOCAL
operator bool()
const {
330 #endif // #ifndef _QORE_QORERWLOCK_H
provides a safe and exception-safe way to hold write locks in Qore, only to be used on the stack...
Definition: QoreRWLock.h:130
DLLLOCAL QoreAutoRWWriteLocker(QoreRWLock &n_l)
creates the object and grabs the write lock
Definition: QoreRWLock.h:147
DLLLOCAL int wrlock()
grabs the write lock
Definition: QoreRWLock.h:68
DLLLOCAL QoreSafeRWWriteLocker(QoreRWLock &n_l)
creates the object and grabs the write lock
Definition: QoreRWLock.h:250
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition: QoreRWLock.h:212
DLLLOCAL ~QoreSafeRWReadLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:199
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition: QoreRWLock.h:275
DLLLOCAL QoreSafeRWReadLocker(QoreRWLock *n_l)
creates the object and grabs the read lock
Definition: QoreRWLock.h:193
DLLLOCAL QoreRWLock()
creates and initializes the lock
Definition: QoreRWLock.h:45
DLLLOCAL ~QoreRWLock()
destroys the lock
Definition: QoreRWLock.h:54
DLLLOCAL ~QoreAutoRWReadLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:120
DLLLOCAL ~QoreAutoRWWriteLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:157
bool locked
lock flag
Definition: QoreRWLock.h:246
bool locked
lock flag
Definition: QoreRWLock.h:183
DLLLOCAL QoreSafeRWReadLocker(QoreRWLock &n_l)
creates the object and grabs the read lock
Definition: QoreRWLock.h:187
provides a safe and exception-safe way to hold write locks in Qore, only to be used on the stack...
Definition: QoreRWLock.h:230
DLLLOCAL int unlock()
unlocks the lock (assumes the lock is locked)
Definition: QoreRWLock.h:83
DLLLOCAL int rdlock()
grabs the read lock
Definition: QoreRWLock.h:63
provides a safe and exception-safe way to hold read locks in Qore, only to be used on the stack...
Definition: QoreRWLock.h:93
DLLLOCAL QoreAutoRWReadLocker(QoreRWLock &n_l)
creates the object and grabs the read lock
Definition: QoreRWLock.h:110
provides a safe and exception-safe way to hold read locks in Qore, only to be used on the stack...
Definition: QoreRWLock.h:167
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:143
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held ...
Definition: QoreRWLock.h:205
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:106
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:219
provides a simple POSIX-threads-based read-write lock
Definition: QoreRWLock.h:35
DLLLOCAL QoreSafeRWWriteLocker(QoreRWLock *n_l)
creates the object and grabs the write lock
Definition: QoreRWLock.h:256
pthread_rwlock_t m
the actual locking primitive wrapped in this class
Definition: QoreRWLock.h:38
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:282
DLLLOCAL QoreAutoRWReadLocker(QoreRWLock *n_l)
creates the object and grabs the read lock
Definition: QoreRWLock.h:115
DLLLOCAL int tryrdlock()
tries to grab the read lock; does not block if unsuccessful
Definition: QoreRWLock.h:73
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:152
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:243
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:180
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held ...
Definition: QoreRWLock.h:268
DLLLOCAL int trywrlock()
tries to grab the write lock; does not block if unsuccessful
Definition: QoreRWLock.h:78
DLLLOCAL ~QoreSafeRWWriteLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:262