[Kst] branches/work/kst/hierarchy/kst/src
Eli Fidler
eli at staikos.net
Mon Dec 11 22:37:15 CET 2006
SVN commit 612574 by fidler:
change isLocked() and isLockedByMe() to lockStatus() and myLockStatus()
fix deadlock in fits
M +22 -13 libkst/rwlock.cpp
M +4 -2 libkst/rwlock.h
M +1 -1 libkstapp/ksteventmonitorentry.cpp
M +4 -1 libkstmath/kstcplugin.cpp
--- branches/work/kst/hierarchy/kst/src/libkst/rwlock.cpp #612573:612574
@@ -161,32 +161,41 @@
}
-bool KstRWLock::isLocked() const {
+KstRWLock::LockStatus KstRWLock::lockStatus() const {
#ifndef ONE_LOCK_TO_RULE_THEM_ALL
- return (_readCount > 0 || _writeCount > 0);
+ QMutexLocker lock(&_mutex);
+
+ if (_writeCount > 0) {
+ return WRITELOCKED;
+ } else if (_readCount > 0) {
+ return READLOCKED;
+ } else {
+ return UNLOCKED;
+ }
#else
-#error isLocked() not supported using the single lock
- return false;
+#error lockStatus() not supported using the single lock
+ return UNLOCKED;
#endif
}
-bool KstRWLock::isLockedByMe() const {
+KstRWLock::LockStatus KstRWLock::myLockStatus() 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;
+ if (_writeCount > 0 && _writeLocker == me) {
+ return WRITELOCKED;
+ } else if (_readCount > 0 && _readLockers.find(me) != _readLockers.end()) {
+ return READLOCKED;
+ } else {
+ return UNLOCKED;
}
#else
-#error isLockedByMe() not supported using the single lock
- return false;
+#error myLockStatus() not supported using the single lock
+ return UNLOCKED;
#endif
}
+
// vim: ts=2 sw=2 et
--- branches/work/kst/hierarchy/kst/src/libkst/rwlock.h #612573:612574
@@ -42,9 +42,11 @@
virtual void unlock() const;
- virtual bool isLocked() const;
- virtual bool isLockedByMe() const;
+ enum LockStatus {UNLOCKED, READLOCKED, WRITELOCKED};
+ virtual LockStatus lockStatus() const;
+ virtual LockStatus myLockStatus() const;
+
protected:
#ifdef ONE_LOCK_TO_RULE_THEM_ALL
static
--- branches/work/kst/hierarchy/kst/src/libkstapp/ksteventmonitorentry.cpp #612573:612574
@@ -131,7 +131,7 @@
_pExpression->collectObjects(_vectorsUsed, _inputScalars, stm);
for (KstScalarMap::ConstIterator i = _inputScalars.begin(); i != _inputScalars.end(); ++i) {
- if (!(*i)->isLockedByMe()) {
+ if ((*i)->myLockStatus() == KstRWLock::UNLOCKED) {
(*i)->readLock();
}
}
--- branches/work/kst/hierarchy/kst/src/libkstmath/kstcplugin.cpp #612573:612574
@@ -520,6 +520,8 @@
bool KstCPlugin::setPlugin(KstSharedPtr<Plugin> plugin) {
// Assumes that this is called with a write lock in place on this object
+ Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED);
+
if (plugin == _plugin) {
return true;
}
@@ -593,6 +595,7 @@
allocateParameters();
_plugin = plugin;
+
return true;
}
@@ -650,7 +653,7 @@
if (!_outputScalars.contains(paramName)) {
KstWriteLocker blockScalarUpdates(&KST::scalarList.lock());
KstScalarPtr s = new KstScalar(KstObjectTag(paramName, tag()), this, scalarValue);
- s->KstObject::writeLock();
+ //s->KstObject::writeLock(); // causes a deadlock
_outputScalars.insert(paramName, s);
++_outScalarCnt;
} else {
More information about the Kst
mailing list