aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Komissarov <abbapoh@gmail.com>2020-10-31 18:33:30 +0100
committerIvan Komissarov <ABBAPOH@gmail.com>2020-11-04 17:06:33 +0000
commit8474ce4c2a280b8ebb46af47e1721c28b0da6209 (patch)
tree6455b4a679809a032208a346eb8a00bb2f5ab5f0
parentd6c136ae8403103200dc8f761a8d0af75146392f (diff)
qt6: use lambdas to pass callables to QtConcurrent::run
It is not possible to use "this" as the 1st argument for run() method since it should be QThreadPool now Change-Id: I69d4291b8a748ea62de7e3b486f8e3e046cd38b4 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--tests/benchmarker/benchmarker.cpp4
-rw-r--r--tests/benchmarker/valgrindrunner.cpp24
2 files changed, 16 insertions, 12 deletions
diff --git a/tests/benchmarker/benchmarker.cpp b/tests/benchmarker/benchmarker.cpp
index 2cc442a72..3c5fcde4e 100644
--- a/tests/benchmarker/benchmarker.cpp
+++ b/tests/benchmarker/benchmarker.cpp
@@ -77,8 +77,8 @@ void Benchmarker::benchmark()
m_baseOutputDir.path() + "/benchmark-data." + m_oldCommit);
ValgrindRunner newDataRetriever(m_activities, m_testProject, newQbsBuildDir,
m_baseOutputDir.path() + "/benchmark-data." + m_newCommit);
- QFuture<void> oldFuture = QtConcurrent::run(&oldDataRetriever, &ValgrindRunner::run);
- QFuture<void> newFuture = QtConcurrent::run(&newDataRetriever, &ValgrindRunner::run);
+ QFuture<void> oldFuture = QtConcurrent::run([&oldDataRetriever]{ oldDataRetriever.run(); });
+ QFuture<void> newFuture = QtConcurrent::run([&newDataRetriever]{ newDataRetriever.run(); });
oldFuture.waitForFinished();
const auto oldValgrindResults = oldDataRetriever.results();
for (const ValgrindResult &valgrindResult : oldValgrindResults) {
diff --git a/tests/benchmarker/valgrindrunner.cpp b/tests/benchmarker/valgrindrunner.cpp
index 174781318..72745dc16 100644
--- a/tests/benchmarker/valgrindrunner.cpp
+++ b/tests/benchmarker/valgrindrunner.cpp
@@ -59,11 +59,11 @@ void ValgrindRunner::run()
{
std::deque<QFuture<void>> futures;
if (m_activities & ActivityResolving)
- futures.push_back(QtConcurrent::run(this, &ValgrindRunner::traceResolving));
+ futures.push_back(QtConcurrent::run([this]{ traceResolving(); }));
if (m_activities & ActivityRuleExecution)
- futures.push_back(QtConcurrent::run(this, &ValgrindRunner::traceRuleExecution));
+ futures.push_back(QtConcurrent::run([this]{ traceRuleExecution(); }));
if (m_activities & ActivityNullBuild)
- futures.push_back(QtConcurrent::run(this, &ValgrindRunner::traceNullBuild));
+ futures.push_back(QtConcurrent::run([this]{ traceNullBuild(); }));
while (!futures.empty()) {
futures.front().waitForFinished();
futures.pop_front();
@@ -100,12 +100,11 @@ void ValgrindRunner::traceActivity(Activity activity, const QString &buildDirCal
{
QString activityString;
QString qbsCommand;
- bool dryRun;
+ bool dryRun = false;
switch (activity) {
case ActivityResolving:
activityString = "resolving";
qbsCommand = "resolve";
- dryRun = false;
break;
case ActivityRuleExecution:
activityString = "rule-execution";
@@ -115,16 +114,21 @@ void ValgrindRunner::traceActivity(Activity activity, const QString &buildDirCal
case ActivityNullBuild:
activityString = "null-build";
qbsCommand = "build";
- dryRun = false;
break;
}
const QString outFileCallgrind = m_baseOutputDir + "/outfile." + activityString + ".callgrind";
const QString outFileMassif = m_baseOutputDir + "/outfile." + activityString + ".massif";
- QFuture<qint64> callGrindFuture = QtConcurrent::run(this, &ValgrindRunner::runCallgrind,
- qbsCommand, buildDirCallgrind, dryRun, outFileCallgrind);
- QFuture<qint64> massifFuture = QtConcurrent::run(this, &ValgrindRunner::runMassif, qbsCommand,
- buildDirMassif, dryRun, outFileMassif);
+ QFuture<qint64> callGrindFuture = QtConcurrent::run(
+ [this, qbsCommand, buildDirCallgrind, dryRun, outFileCallgrind]
+ {
+ return runCallgrind(qbsCommand, buildDirCallgrind, dryRun, outFileCallgrind);
+ });
+ QFuture<qint64> massifFuture = QtConcurrent::run(
+ [this, qbsCommand, buildDirMassif, dryRun, outFileMassif]
+ {
+ return runMassif(qbsCommand, buildDirMassif, dryRun, outFileMassif);
+ });
callGrindFuture.waitForFinished();
massifFuture.waitForFinished();
addToResults(ValgrindResult(activity, callGrindFuture.result(), massifFuture.result()));