34#ifndef _QORE_CLASS_RWLOCK
36#define _QORE_CLASS_RWLOCK
38#include "qore/AbstractSmartLock.h"
43typedef std::map<int, int> tid_map_t;
52typedef std::map<int, VLock*> vlock_map_t;
54class RWLock :
public AbstractSmartLock {
56 DLLEXPORT RWLock(
bool p =
false);
58 DLLEXPORT
virtual ~RWLock();
62 DLLEXPORT
int tryReadLock();
64 DLLEXPORT
int numReaders();
66 DLLLOCAL
int getReadWaiting()
const {
69 DLLLOCAL
int getWriteWaiting()
const {
73 DLLLOCAL
bool lockOwner()
const {
77 return readLockOwner();
80 DLLLOCAL
bool writeLockOwner()
const {
84 DLLLOCAL
bool readLockOwner()
const {
86 if (tid > -1 || tid == Lock_Deleted || !num_readers)
92 return tmap.find(mtid) == tmap.end() ? false :
true;
95 DLLLOCAL
virtual const char* getName()
const {
108 DLLLOCAL
int cleanup_read_lock_intern(tid_map_t::iterator i);
109 DLLLOCAL
void mark_read_lock_intern(
int mtid, VLock *nvl);
110 DLLLOCAL
void release_read_lock_intern(tid_map_t::iterator i);
111 DLLLOCAL
int grab_read_lock_intern(
int mtid, VLock *nvl,
int64 timeout_ms,
ExceptionSink *xsink);
112 DLLLOCAL
void set_initial_read_lock_intern(
int mtid, VLock *nvl);
114 DLLLOCAL
virtual int cleanupImpl();
115 DLLLOCAL
virtual void signalAllImpl();
116 DLLLOCAL
virtual void signalImpl();
117 DLLLOCAL
virtual int releaseImpl();
119 DLLLOCAL
virtual int grabImpl(
int mtid, VLock *nvl,
ExceptionSink *xsink,
int64 timeout_ms = 0);
120 DLLLOCAL
virtual int tryGrabImpl(
int mtid, VLock *nvl);
provides a safe and exception-safe way to hold locks in Qore, only to be used on the stack,...
Definition: QoreThreadLock.h:136
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:50
a thread condition class implementing a wrapper for pthread_cond_t
Definition: QoreCondition.h:45
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:260
DLLEXPORT int q_gettid() noexcept
returns the current TID number