34 #ifndef _QORE_CLASS_RWLOCK
36 #define _QORE_CLASS_RWLOCK
38 #include "qore/intern/AbstractSmartLock.h"
39 #include "qore/intern/VLock.h"
44 typedef std::map<int, int> tid_map_t;
51 class RWLock :
public AbstractSmartLock {
53 DLLLOCAL RWLock(
bool p =
false);
56 DLLLOCAL
virtual ~RWLock();
61 DLLLOCAL
int tryReadLock();
64 DLLLOCAL
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 {
return "RWLock"; }
106 DLLLOCAL
int cleanup_read_lock_intern(tid_map_t::iterator i);
107 DLLLOCAL
void mark_read_lock_intern(
int mtid, VLock *nvl);
108 DLLLOCAL
void release_read_lock_intern(tid_map_t::iterator i);
109 DLLLOCAL
int grab_read_lock_intern(
int mtid, VLock *nvl,
int64 timeout_ms,
ExceptionSink *xsink);
110 DLLLOCAL
void set_initial_read_lock_intern(
int mtid, VLock *nvl);
112 DLLLOCAL
virtual int cleanupImpl();
113 DLLLOCAL
virtual void signalAllImpl();
114 DLLLOCAL
virtual void signalImpl();
115 DLLLOCAL
virtual int releaseImpl();
117 DLLLOCAL
virtual int grabImpl(
int mtid, VLock *nvl,
ExceptionSink *xsink,
int64 timeout_ms = 0);
118 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:48
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