34 #ifndef _QORE_QORERWLOCK_H
35 #define _QORE_QORERWLOCK_H
57 pthread_rwlock_init(&m, 0);
66 pthread_rwlock_destroy(&m);
72 return pthread_rwlock_rdlock(&m);
77 return pthread_rwlock_wrlock(&m);
82 return pthread_rwlock_tryrdlock(&m);
87 return pthread_rwlock_trywrlock(&m);
92 return pthread_rwlock_unlock(&m);
107 DLLLOCAL QoreAutoRWReadLocker& operator=(
const QoreAutoRWReadLocker&);
110 DLLLOCAL
void *
operator new(size_t);
144 DLLLOCAL QoreAutoRWWriteLocker& operator=(
const QoreAutoRWWriteLocker&);
147 DLLLOCAL
void *
operator new(size_t);
181 DLLLOCAL QoreSafeRWReadLocker& operator=(
const QoreSafeRWReadLocker&);
184 DLLLOCAL
void *
operator new(size_t);
244 DLLLOCAL QoreSafeRWWriteLocker& operator=(
const QoreSafeRWWriteLocker&);
247 DLLLOCAL
void *
operator new(size_t);
296 class QoreOptionalRWWriteLocker {
301 DLLLOCAL QoreOptionalRWWriteLocker(
QoreRWLock* n_l) : l(n_l->trywrlock() ? 0 : n_l) {
304 DLLLOCAL QoreOptionalRWWriteLocker(
QoreRWLock& n_l) : l(n_l.trywrlock() ? 0 : &n_l) {
307 DLLLOCAL ~QoreOptionalRWWriteLocker() {
312 DLLLOCAL
operator bool()
const {
317 class QoreOptionalRWReadLocker {
322 DLLLOCAL QoreOptionalRWReadLocker(
QoreRWLock* n_l) : l(n_l->tryrdlock() ? 0 : n_l) {
325 DLLLOCAL QoreOptionalRWReadLocker(
QoreRWLock& n_l) : l(n_l.tryrdlock() ? 0 : &n_l) {
328 DLLLOCAL ~QoreOptionalRWReadLocker() {
333 DLLLOCAL
operator bool()
const {
338 #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:138
DLLLOCAL QoreAutoRWWriteLocker(QoreRWLock &n_l)
creates the object and grabs the write lock
Definition: QoreRWLock.h:155
DLLLOCAL int wrlock()
grabs the write lock
Definition: QoreRWLock.h:76
DLLLOCAL QoreSafeRWWriteLocker(QoreRWLock &n_l)
creates the object and grabs the write lock
Definition: QoreRWLock.h:258
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition: QoreRWLock.h:220
DLLLOCAL ~QoreSafeRWReadLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:207
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition: QoreRWLock.h:283
DLLLOCAL QoreSafeRWReadLocker(QoreRWLock *n_l)
creates the object and grabs the read lock
Definition: QoreRWLock.h:201
DLLLOCAL QoreRWLock()
creates and initializes the lock
Definition: QoreRWLock.h:53
DLLLOCAL ~QoreRWLock()
destroys the lock
Definition: QoreRWLock.h:62
DLLLOCAL ~QoreAutoRWReadLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:128
DLLLOCAL ~QoreAutoRWWriteLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:165
bool locked
lock flag
Definition: QoreRWLock.h:254
bool locked
lock flag
Definition: QoreRWLock.h:191
DLLLOCAL QoreSafeRWReadLocker(QoreRWLock &n_l)
creates the object and grabs the read lock
Definition: QoreRWLock.h:195
provides a safe and exception-safe way to hold write locks in Qore, only to be used on the stack...
Definition: QoreRWLock.h:238
DLLLOCAL int unlock()
unlocks the lock (assumes the lock is locked)
Definition: QoreRWLock.h:91
DLLLOCAL int rdlock()
grabs the read lock
Definition: QoreRWLock.h:71
provides a safe and exception-safe way to hold read locks in Qore, only to be used on the stack...
Definition: QoreRWLock.h:101
DLLLOCAL QoreAutoRWReadLocker(QoreRWLock &n_l)
creates the object and grabs the read lock
Definition: QoreRWLock.h:118
provides a safe and exception-safe way to hold read locks in Qore, only to be used on the stack...
Definition: QoreRWLock.h:175
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:151
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held ...
Definition: QoreRWLock.h:213
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:114
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:227
provides a simple POSIX-threads-based read-write lock
Definition: QoreRWLock.h:43
DLLLOCAL QoreSafeRWWriteLocker(QoreRWLock *n_l)
creates the object and grabs the write lock
Definition: QoreRWLock.h:264
pthread_rwlock_t m
the actual locking primitive wrapped in this class
Definition: QoreRWLock.h:46
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:290
DLLLOCAL QoreAutoRWReadLocker(QoreRWLock *n_l)
creates the object and grabs the read lock
Definition: QoreRWLock.h:123
DLLLOCAL int tryrdlock()
tries to grab the read lock; does not block if unsuccessful
Definition: QoreRWLock.h:81
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:160
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:251
QoreRWLock * l
the pointer to the lock that will be managed
Definition: QoreRWLock.h:188
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held ...
Definition: QoreRWLock.h:276
DLLLOCAL int trywrlock()
tries to grab the write lock; does not block if unsuccessful
Definition: QoreRWLock.h:86
DLLLOCAL ~QoreSafeRWWriteLocker()
destroys the object and releases the lock
Definition: QoreRWLock.h:270