summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2016-01-27 15:44:31 +0100
committerEike Ziller <eike.ziller@theqtcompany.com>2016-01-28 13:50:14 +0000
commit67e952e888dcb43466a031015e1917890c640470 (patch)
tree4d5aa616678683c88d254012d41e04f8a7035302
parent58be2708a353128fd83555d8e20b5a32d6efd6d7 (diff)
downloadqt-creator-67e952e888dcb43466a031015e1917890c640470.tar.gz
QMakeProjectManager: Reduce priority of parsing threads.
Task-number: QTCREATORBUG-14640 Change-Id: I32b47888ecf3627bc21649a0c922216fb9e714a6 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
-rw-r--r--src/libs/utils/runextensions.h26
-rw-r--r--src/plugins/qmakeprojectmanager/qmakenodes.cpp1
2 files changed, 26 insertions, 1 deletions
diff --git a/src/libs/utils/runextensions.h b/src/libs/utils/runextensions.h
index 7427dbfb13..433ac523a9 100644
--- a/src/libs/utils/runextensions.h
+++ b/src/libs/utils/runextensions.h
@@ -28,6 +28,7 @@
#include "qtcassert.h"
+#include <QCoreApplication>
#include <QFuture>
#include <QFutureInterface>
#include <QRunnable>
@@ -581,6 +582,10 @@ public:
void run() override
{
+ if (priority != QThread::InheritPriority)
+ if (QThread *thread = QThread::currentThread())
+ if (thread != qApp->thread())
+ thread->setPriority(priority);
if (futureInterface.isCanceled()) {
futureInterface.reportFinished();
return;
@@ -593,6 +598,11 @@ public:
futureInterface.setThreadPool(pool);
}
+ void setThreadPriority(QThread::Priority p)
+ {
+ priority = p;
+ }
+
private:
using Data = std::tuple<typename std::decay<Function>::type, typename std::decay<Args>::type...>;
@@ -605,6 +615,7 @@ private:
Data data;
QFutureInterface<ResultType> futureInterface;
+ QThread::Priority priority = QThread::InheritPriority;
};
} // Internal
@@ -662,16 +673,29 @@ QFuture<ResultType> runAsync(Function &&function, Args&&... args)
}
template <typename ResultType, typename Function, typename... Args>
-QFuture<ResultType> runAsync(QThreadPool *pool, Function &&function, Args&&... args)
+QFuture<ResultType> runAsync(QThreadPool *pool, QThread::Priority priority,
+ Function &&function, Args&&... args)
{
auto job = new Internal::AsyncJob<ResultType,Function,Args...>
(std::forward<Function>(function), std::forward<Args>(args)...);
job->setThreadPool(pool);
+ job->setThreadPriority(priority);
QFuture<ResultType> future = job->future();
pool->start(job);
return future;
}
+template <typename ResultType, typename Function, typename... Args,
+ typename = typename std::enable_if<
+ !std::is_same<typename std::decay<Function>::type, QThread::Priority>::value
+ >::type>
+QFuture<ResultType> runAsync(QThreadPool *pool,
+ Function &&function, Args&&... args)
+{
+ return runAsync<ResultType>(pool, QThread::InheritPriority, std::forward<Function>(function),
+ std::forward<Args>(args)...);
+}
+
} // Utils
#endif // RUNEXTENSIONS_H
diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
index 2808a6dd60..350f57fc2a 100644
--- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp
+++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp
@@ -1801,6 +1801,7 @@ void QmakeProFileNode::asyncUpdate()
m_parseFutureWatcher.waitForFinished();
EvalInput input = evalInput();
QFuture<EvalResult *> future = Utils::runAsync<EvalResult *>(ProjectExplorerPlugin::sharedThreadPool(),
+ QThread::LowestPriority,
&QmakeProFileNode::asyncEvaluate,
this, input);
m_parseFutureWatcher.setFuture(future);