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);
255 DLLLOCAL
void*
operator new(size_t) =
delete;
272 DLLLOCAL
void *
operator new(size_t);
321class QoreOptionalRWWriteLocker {
326 DLLLOCAL QoreOptionalRWWriteLocker(
QoreRWLock* n_l) : l(n_l->trywrlock() ? 0 : n_l) {
329 DLLLOCAL QoreOptionalRWWriteLocker(
QoreRWLock& n_l) : l(n_l.trywrlock() ? 0 : &n_l) {
332 DLLLOCAL ~QoreOptionalRWWriteLocker() {
337 DLLLOCAL
operator bool()
const {
342class QoreOptionalRWReadLocker {
347 DLLLOCAL QoreOptionalRWReadLocker(
QoreRWLock* n_l) : l(n_l->tryrdlock() ? 0 : n_l) {
350 DLLLOCAL QoreOptionalRWReadLocker(
QoreRWLock& n_l) : l(n_l.tryrdlock() ? 0 : &n_l) {
353 DLLLOCAL ~QoreOptionalRWReadLocker() {
358 DLLLOCAL
operator bool()
const {
363class qore_var_rwlock_priv;
368 DLLLOCAL QoreVarRWLock(
const QoreVarRWLock&);
370 DLLLOCAL QoreVarRWLock& operator=(
const QoreVarRWLock&);
373 qore_var_rwlock_priv* priv;
375 DLLLOCAL QoreVarRWLock(qore_var_rwlock_priv* p);
378 DLLLOCAL QoreVarRWLock();
381 DLLLOCAL ~QoreVarRWLock();
384 DLLLOCAL
void wrlock();
387 DLLLOCAL
int trywrlock();
390 DLLLOCAL
void unlock();
393 DLLLOCAL
void rdlock();
396 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(QoreRWLock *n_l)
creates the object and grabs the read lock. If parameter is null then no function is performed.
Definition QoreRWLock.h:127
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
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 write locks in Qore, only to be used on the stack,...
Definition QoreRWLock.h:144
DLLLOCAL QoreAutoRWWriteLocker(QoreRWLock &n_l)
creates the object and grabs the write lock
Definition QoreRWLock.h:161
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
DLLLOCAL QoreAutoRWWriteLocker(QoreRWLock *n_l)
creates the object and grabs the write lock. If parameter is null then no function is performed.
Definition QoreRWLock.h:166
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 handoffTo(QoreRWLock &n)
Handoff to another read lock.
Definition QoreRWLock.h:232
DLLLOCAL QoreSafeRWReadLocker()
creates an empty object
Definition QoreRWLock.h:186
DLLLOCAL QoreSafeRWReadLocker(QoreRWLock *n_l)
creates the object and grabs the read lock
Definition QoreRWLock.h:196
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition QoreRWLock.h:217
bool locked
lock flag
Definition QoreRWLock.h:245
DLLLOCAL ~QoreSafeRWReadLocker()
destroys the object and releases the lock
Definition QoreRWLock.h:202
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held
Definition QoreRWLock.h:209
DLLLOCAL QoreSafeRWReadLocker(QoreRWLock &n_l)
creates the object and grabs the read lock
Definition QoreRWLock.h:190
QoreRWLock * l
the pointer to the lock that will be managed
Definition QoreRWLock.h:242
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:225
provides a safe and exception-safe way to hold write locks in Qore, only to be used on the stack,...
Definition QoreRWLock.h:263
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition QoreRWLock.h:308
DLLLOCAL QoreSafeRWWriteLocker(QoreRWLock &n_l)
creates the object and grabs the write lock
Definition QoreRWLock.h:283
QoreRWLock * l
the pointer to the lock that will be managed
Definition QoreRWLock.h:276
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held
Definition QoreRWLock.h:301
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:315
DLLLOCAL QoreSafeRWWriteLocker(QoreRWLock *n_l)
creates the object and grabs the write lock
Definition QoreRWLock.h:289
DLLLOCAL ~QoreSafeRWWriteLocker()
destroys the object and releases the lock
Definition QoreRWLock.h:295
bool locked
lock flag
Definition QoreRWLock.h:279
DLLEXPORT int q_gettid() noexcept
returns the current TID number