34#ifndef _QORE_QORERWLOCK_H 
   35#define _QORE_QORERWLOCK_H 
   54        pthread_rwlock_init(&
m, 0);
 
 
   63        pthread_rwlock_destroy(&
m);
 
 
   69        return pthread_rwlock_wrlock(&
m);
 
 
   74        return pthread_rwlock_trywrlock(&
m);
 
 
   79        return pthread_rwlock_unlock(&
m);
 
 
   84        return pthread_rwlock_rdlock(&
m);
 
 
   89        return pthread_rwlock_tryrdlock(&
m);
 
 
 
  113    DLLLOCAL 
void *
operator new(size_t);
 
 
  152    DLLLOCAL 
void *
operator new(size_t);
 
 
  254    DLLLOCAL 
void* 
operator new(size_t) = 
delete;
 
 
  271    DLLLOCAL 
void *
operator new(size_t);
 
 
  320class QoreOptionalRWWriteLocker {
 
  325    DLLLOCAL QoreOptionalRWWriteLocker(
QoreRWLock* n_l) : l(n_l->trywrlock() ? 0 : n_l) {
 
  328    DLLLOCAL QoreOptionalRWWriteLocker(
QoreRWLock& n_l) : l(n_l.trywrlock() ? 0 : &n_l) {
 
  331    DLLLOCAL ~QoreOptionalRWWriteLocker() {
 
  336    DLLLOCAL 
operator bool()
 const {
 
  341class QoreOptionalRWReadLocker {
 
  346    DLLLOCAL QoreOptionalRWReadLocker(
QoreRWLock* n_l) : l(n_l->tryrdlock() ? 0 : n_l) {
 
  349    DLLLOCAL QoreOptionalRWReadLocker(
QoreRWLock& n_l) : l(n_l.tryrdlock() ? 0 : &n_l) {
 
  352    DLLLOCAL ~QoreOptionalRWReadLocker() {
 
  357    DLLLOCAL 
operator bool()
 const {
 
  362class qore_var_rwlock_priv;
 
  365    friend class qore_var_rwlock_priv;
 
  367    DLLLOCAL QoreVarRWLock();
 
  370    DLLLOCAL ~QoreVarRWLock();
 
  373    DLLLOCAL 
void wrlock();
 
  376    DLLLOCAL 
int trywrlock();
 
  379    DLLLOCAL 
void unlock();
 
  382    DLLLOCAL 
void rdlock();
 
  385    DLLLOCAL 
int tryrdlock();
 
  388    qore_var_rwlock_priv* priv;
 
  390    DLLLOCAL QoreVarRWLock(qore_var_rwlock_priv* p);
 
  393    QoreVarRWLock(
const QoreVarRWLock&) = 
delete;
 
  394    QoreVarRWLock& operator=(
const QoreVarRWLock&) = 
delete;
 
provides a safe and exception-safe way to hold read locks in Qore, only to be used on the stack,...
Definition QoreRWLock.h:104
 
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:126
 
DLLLOCAL ~QoreAutoRWReadLocker()
destroys the object and releases the lock
Definition QoreRWLock.h:132
 
QoreRWLock * l
the pointer to the lock that will be managed
Definition QoreRWLock.h:117
 
DLLLOCAL QoreAutoRWReadLocker(QoreRWLock &n_l)
creates the object and grabs the read lock
Definition QoreRWLock.h:121
 
provides a safe and exception-safe way to hold write locks in Qore, only to be used on the stack,...
Definition QoreRWLock.h:143
 
DLLLOCAL QoreAutoRWWriteLocker(QoreRWLock &n_l)
creates the object and grabs the write lock
Definition QoreRWLock.h:160
 
DLLLOCAL ~QoreAutoRWWriteLocker()
destroys the object and releases the lock
Definition QoreRWLock.h:171
 
QoreRWLock * l
the pointer to the lock that will be managed
Definition QoreRWLock.h:156
 
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:165
 
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:94
 
DLLLOCAL ~QoreRWLock()
destroys the lock
Definition QoreRWLock.h:59
 
DLLLOCAL int wrlock()
grabs the write lock
Definition QoreRWLock.h:68
 
DLLLOCAL QoreRWLock()
creates and initializes the lock
Definition QoreRWLock.h:50
 
DLLLOCAL int trywrlock()
tries to grab the write lock; does not block if unsuccessful; returns 0 if successful
Definition QoreRWLock.h:73
 
DLLLOCAL int unlock()
unlocks the lock (assumes the lock is locked)
Definition QoreRWLock.h:78
 
DLLLOCAL int rdlock()
grabs the read lock
Definition QoreRWLock.h:83
 
DLLLOCAL int tryrdlock()
tries to grab the read lock; does not block if unsuccessful; returns 0 if successful
Definition QoreRWLock.h:88
 
provides a safe and exception-safe way to hold read locks in Qore, only to be used on the stack,...
Definition QoreRWLock.h:182
 
DLLLOCAL void handoffTo(QoreRWLock &n)
Handoff to another read lock.
Definition QoreRWLock.h:231
 
DLLLOCAL QoreSafeRWReadLocker()
creates an empty object
Definition QoreRWLock.h:185
 
DLLLOCAL QoreSafeRWReadLocker(QoreRWLock *n_l)
creates the object and grabs the read lock
Definition QoreRWLock.h:195
 
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition QoreRWLock.h:216
 
bool locked
lock flag
Definition QoreRWLock.h:244
 
DLLLOCAL ~QoreSafeRWReadLocker()
destroys the object and releases the lock
Definition QoreRWLock.h:201
 
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held
Definition QoreRWLock.h:208
 
DLLLOCAL QoreSafeRWReadLocker(QoreRWLock &n_l)
creates the object and grabs the read lock
Definition QoreRWLock.h:189
 
QoreRWLock * l
the pointer to the lock that will be managed
Definition QoreRWLock.h:241
 
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:224
 
provides a safe and exception-safe way to hold write locks in Qore, only to be used on the stack,...
Definition QoreRWLock.h:262
 
DLLLOCAL void unlock()
unlocks the object and updates the locked flag, assumes that the lock is held
Definition QoreRWLock.h:307
 
DLLLOCAL QoreSafeRWWriteLocker(QoreRWLock &n_l)
creates the object and grabs the write lock
Definition QoreRWLock.h:282
 
QoreRWLock * l
the pointer to the lock that will be managed
Definition QoreRWLock.h:275
 
DLLLOCAL void lock()
locks the object and updates the locked flag, assumes that the lock is not already held
Definition QoreRWLock.h:300
 
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:314
 
DLLLOCAL QoreSafeRWWriteLocker(QoreRWLock *n_l)
creates the object and grabs the write lock
Definition QoreRWLock.h:288
 
DLLLOCAL ~QoreSafeRWWriteLocker()
destroys the object and releases the lock
Definition QoreRWLock.h:294
 
bool locked
lock flag
Definition QoreRWLock.h:278
 
DLLEXPORT int q_gettid() noexcept
returns the current TID number