[Kst] branches/work/kst/hierarchy/kst/src/libkst
Eli Fidler
eli at staikos.net
Thu Nov 30 19:53:57 CET 2006
SVN commit 609425 by fidler:
add isLocked() and isLockedByMe()
M +26 -0 rwlock.cpp
M +3 -0 rwlock.h
--- branches/work/kst/hierarchy/kst/src/libkst/rwlock.cpp #609424:609425
@@ -161,4 +161,30 @@
}
+bool KstRWLock::isLocked() const {
+#ifndef ONE_LOCK_TO_RULE_THEM_ALL
+ return (_readCount > 0 || _writeCount > 0);
+#else
+#error isLocked() not supported using the single lock
+#endif
+}
+
+
+bool KstRWLock::isLockedByMe() const {
+#ifndef ONE_LOCK_TO_RULE_THEM_ALL
+ QMutexLocker lock(&_mutex);
+
+ Qt::HANDLE me = QThread::currentThread();
+
+ if (_readCount > 0) {
+ return (_readLockers.find(me) != _readLockers.end());
+ } else if (_writeCount > 0) {
+ return (_writeLocker == me);
+ } else if (_readCount == 0 && _writeCount == 0) {
+ return false;
+ }
+#else
+#error isLockedByMe() not supported using the single lock
+#endif
+}
// vim: ts=2 sw=2 et
--- branches/work/kst/hierarchy/kst/src/libkst/rwlock.h #609424:609425
@@ -42,6 +42,9 @@
virtual void unlock() const;
+ virtual bool isLocked() const;
+ virtual bool isLockedByMe() const;
+
protected:
#ifdef ONE_LOCK_TO_RULE_THEM_ALL
static
More information about the Kst
mailing list