summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qmutex.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-06-30 15:11:39 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-06-30 15:23:11 (GMT)
commit8aebcf559e42a6e93d343b1bd46f5abb4a10cb7f (patch)
tree3f83a48fde32136837e6f33d5cb60caa041052b6 /src/corelib/thread/qmutex.cpp
parentbcba2d2d80758832e5abdfaa6baca872b81bb912 (diff)
downloadQt-8aebcf559e42a6e93d343b1bd46f5abb4a10cb7f.zip
Qt-8aebcf559e42a6e93d343b1bd46f5abb4a10cb7f.tar.gz
Qt-8aebcf559e42a6e93d343b1bd46f5abb4a10cb7f.tar.bz2
QMutex: remove debug warnings.
d->owner is not tracked correctly when the new inline (un)lock function are called. And there is no way to make it work reliably as one could mix application compiled in release with Qt in debug. So QMutex could display lots of false warnings. Better to remove them. Reviewed-by: Trond
Diffstat (limited to 'src/corelib/thread/qmutex.cpp')
-rw-r--r--src/corelib/thread/qmutex.cpp48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index eb6f729..b85a22d 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -159,11 +159,6 @@ void QMutex::lock()
bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
if (!isLocked) {
-#ifndef QT_NO_DEBUG
- if (d->owner == self)
- qWarning() << "QMutex::lock: Deadlock detected in thread" << d->owner;
-#endif
-
// didn't get the lock, wait for it
isLocked = d->wait();
Q_ASSERT_X(isLocked, "QMutex::lock",
@@ -179,18 +174,11 @@ void QMutex::lock()
return;
}
-#ifndef QT_NO_DEBUG
- self = QThread::currentThreadId();
-#endif
bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
if (!isLocked) {
lockInternal();
}
-
-#ifndef QT_NO_DEBUG
- d->owner = self;
-#endif
}
/*!
@@ -236,18 +224,12 @@ bool QMutex::tryLock()
return isLocked;
}
-#ifndef QT_NO_DEBUG
- self = QThread::currentThreadId();
-#endif
bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1);
if (!isLocked) {
// some other thread has the mutex locked, or we tried to
// recursively lock an non-recursive mutex
return isLocked;
}
-#ifndef QT_NO_DEBUG
- d->owner = self;
-#endif
return isLocked;
}
@@ -304,9 +286,6 @@ bool QMutex::tryLock(int timeout)
return true;
}
-#ifndef QT_NO_DEBUG
- self = QThread::currentThreadId();
-#endif
bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
if (!isLocked) {
// didn't get the lock, wait for it
@@ -317,9 +296,6 @@ bool QMutex::tryLock(int timeout)
if (!isLocked)
return false;
}
-#ifndef QT_NO_DEBUG
- d->owner = self;
-#endif
return true;
}
@@ -334,12 +310,6 @@ bool QMutex::tryLock(int timeout)
void QMutex::unlock()
{
QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
-#ifndef QT_NO_DEBUG
- //note: if the mutex has been locked with (try)lockInline, d->owner could have not been set, and this would be a false warning
- if ((d->owner || d->recursive) && d->owner != QThread::currentThreadId())
- qWarning("QMutex::unlock(): A mutex must be unlocked in the same thread that locked it.");
-#endif
-
if (d->recursive) {
if (!--d->count) {
@@ -348,9 +318,6 @@ void QMutex::unlock()
d->wakeUp();
}
} else {
-#ifndef QT_NO_DEBUG
- d->owner = 0;
-#endif
if (!d->contenders.testAndSetRelease(1, 0))
d->wakeUp();
}
@@ -490,19 +457,11 @@ void QMutex::lockInternal()
enum { AdditionalSpins = 20, SpinCountPenalizationDivisor = 4 };
const int maximumSpinCount = lastSpinCount + AdditionalSpins;
-#ifndef QT_NO_DEBUG
- Qt::HANDLE self = QThread::currentThreadId();
-#endif
-
do {
if (spinCount++ > maximumSpinCount) {
// puts("spinning useless, sleeping");
bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0;
if (!isLocked) {
-#ifndef QT_NO_DEBUG
- if (d->owner == self)
- qWarning() << "QMutex::lock: Deadlock detected in thread" << d->owner;
-#endif
// didn't get the lock, wait for it
isLocked = d->wait();
@@ -523,10 +482,6 @@ void QMutex::lockInternal()
d->lastSpinCount = spinCount >= 0
? qMax(lastSpinCount, spinCount)
: lastSpinCount + spinCount;
-
-#ifndef QT_NO_DEBUG
- d->owner = self;
-#endif
}
/*!
@@ -534,9 +489,6 @@ void QMutex::lockInternal()
*/
void QMutex::unlockInternal()
{
-#ifndef QT_NO_DEBUG
- static_cast<QMutexPrivate *>(d)->owner = 0;
-#endif
static_cast<QMutexPrivate *>(d)->wakeUp();
}