summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorVolker Krause <volker.krause@kdab.com>2016-01-06 15:39:01 +0100
committerVolker Krause <volker.krause@kdab.com>2016-01-07 07:59:37 +0000
commiteb0b03c579cfd90ebfeeaa115955a0a924c9ce0f (patch)
tree13f88327fd64ff03c79a17d06b9b156a8b6b41b2 /src/corelib/thread
parentd3fe4f066f70bc8e4aef06b963444ecdbc3dd00f (diff)
QPair<QRunnable*, int> is too large for QList to be efficient-ish.
Qt3D is making heavy use of this, causing the QList node allocations to be among the top 10 per frame allocation sources. Switching to QVector fixes that. Change-Id: I3b4df329710f82bf8d6797ea1f0c79b288a08063 Reviewed-by: Sean Harmer <sean.harmer@kdab.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qthreadpool.cpp10
-rw-r--r--src/corelib/thread/qthreadpool_p.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp
index b6b3be8d92..e4a5368281 100644
--- a/src/corelib/thread/qthreadpool.cpp
+++ b/src/corelib/thread/qthreadpool.cpp
@@ -204,8 +204,8 @@ void QThreadPoolPrivate::enqueueTask(QRunnable *runnable, int priority)
++runnable->ref;
// put it on the queue
- QList<QPair<QRunnable *, int> >::const_iterator begin = queue.constBegin();
- QList<QPair<QRunnable *, int> >::const_iterator it = queue.constEnd();
+ QVector<QPair<QRunnable *, int> >::const_iterator begin = queue.constBegin();
+ QVector<QPair<QRunnable *, int> >::const_iterator it = queue.constEnd();
if (it != begin && priority > (*(it - 1)).second)
it = std::upper_bound(begin, --it, priority);
queue.insert(it - begin, qMakePair(runnable, priority));
@@ -299,7 +299,7 @@ bool QThreadPoolPrivate::waitForDone(int msecs)
void QThreadPoolPrivate::clear()
{
QMutexLocker locker(&mutex);
- for (QList<QPair<QRunnable *, int> >::const_iterator it = queue.constBegin();
+ for (QVector<QPair<QRunnable *, int> >::const_iterator it = queue.constBegin();
it != queue.constEnd(); ++it) {
QRunnable* r = it->first;
if (r->autoDelete() && !--r->ref)
@@ -319,8 +319,8 @@ bool QThreadPoolPrivate::stealRunnable(QRunnable *runnable)
return false;
{
QMutexLocker locker(&mutex);
- QList<QPair<QRunnable *, int> >::iterator it = queue.begin();
- QList<QPair<QRunnable *, int> >::iterator end = queue.end();
+ QVector<QPair<QRunnable *, int> >::iterator it = queue.begin();
+ QVector<QPair<QRunnable *, int> >::iterator end = queue.end();
while (it != end) {
if (it->first == runnable) {
diff --git a/src/corelib/thread/qthreadpool_p.h b/src/corelib/thread/qthreadpool_p.h
index 34728ed3e2..b03eefcc94 100644
--- a/src/corelib/thread/qthreadpool_p.h
+++ b/src/corelib/thread/qthreadpool_p.h
@@ -83,7 +83,7 @@ public:
QSet<QThreadPoolThread *> allThreads;
QQueue<QThreadPoolThread *> waitingThreads;
QQueue<QThreadPoolThread *> expiredThreads;
- QList<QPair<QRunnable *, int> > queue;
+ QVector<QPair<QRunnable *, int> > queue;
QWaitCondition noActiveThreads;
bool isExiting;