summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2010-10-01 07:45:42 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2010-12-20 15:49:42 (GMT)
commit87bab705ded31559941020d3c500f43f571f9c16 (patch)
tree9a6c8b842852528adf10b9b6a454753b52e303d6 /src
parentfeb0b0cd47808a77a048c6a13686d39a0540a488 (diff)
downloadQt-87bab705ded31559941020d3c500f43f571f9c16.zip
Qt-87bab705ded31559941020d3c500f43f571f9c16.tar.gz
Qt-87bab705ded31559941020d3c500f43f571f9c16.tar.bz2
Disable spinning under lock contention on single CPU machines
Spinning is just wasted time on these systems. Reviewed-by: joao
Diffstat (limited to 'src')
-rw-r--r--src/corelib/thread/qmutex.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index 19e2457..54b3ed4 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -429,6 +429,16 @@ void QMutex::unlock()
void QMutex::lockInternal()
{
QMutexPrivate *d = static_cast<QMutexPrivate *>(this->d);
+
+ if (QThread::idealThreadCount() == 1) {
+ // don't spin on single cpu machines
+ bool isLocked = d->wait();
+ Q_ASSERT_X(isLocked, "QMutex::lock",
+ "Internal error, infinite wait has timed out.");
+ Q_UNUSED(isLocked);
+ return;
+ }
+
int spinCount = 0;
int lastSpinCount = d->lastSpinCount;