tst_QMimeDatabase: use QFutureSynchronizer
Replace a list of QFuture<void>s and a loop that calls waitForFinished() on each of them with a QFutureSynchronizer<void>, which does exactly that. Change-Id: I1f2e90169a5b2949bd8cb9d1009a5a7af1500139 Reviewed-by: David Faure <faure@kde.org>
This commit is contained in:
parent
c4cef6fae9
commit
ea6946318f
@ -46,8 +46,8 @@
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QTextStream>
|
||||
#include <QFutureSynchronizer>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
#include <QtConcurrent/QFuture>
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
@ -752,17 +752,16 @@ void tst_QMimeDatabase::fromThreads()
|
||||
{
|
||||
QThreadPool::globalInstance()->setMaxThreadCount(20);
|
||||
// Note that data-based tests cannot be used here (QTest::fetchData asserts).
|
||||
QList<QFuture<void> > futures;
|
||||
futures << QtConcurrent::run(this, &tst_QMimeDatabase::mimeTypeForName);
|
||||
futures << QtConcurrent::run(this, &tst_QMimeDatabase::aliases);
|
||||
futures << QtConcurrent::run(this, &tst_QMimeDatabase::allMimeTypes);
|
||||
futures << QtConcurrent::run(this, &tst_QMimeDatabase::icons);
|
||||
futures << QtConcurrent::run(this, &tst_QMimeDatabase::inheritance);
|
||||
futures << QtConcurrent::run(this, &tst_QMimeDatabase::knownSuffix);
|
||||
futures << QtConcurrent::run(this, &tst_QMimeDatabase::mimeTypeForFileWithContent);
|
||||
futures << QtConcurrent::run(this, &tst_QMimeDatabase::allMimeTypes); // a second time
|
||||
Q_FOREACH (QFuture<void> f, futures)
|
||||
f.waitForFinished();
|
||||
QFutureSynchronizer<void> sync;
|
||||
sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::mimeTypeForName));
|
||||
sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::aliases));
|
||||
sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::allMimeTypes));
|
||||
sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::icons));
|
||||
sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::inheritance));
|
||||
sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::knownSuffix));
|
||||
sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::mimeTypeForFileWithContent));
|
||||
sync.addFuture(QtConcurrent::run(this, &tst_QMimeDatabase::allMimeTypes)); // a second time
|
||||
// sync dtor blocks waiting for finished
|
||||
}
|
||||
|
||||
static bool runUpdateMimeDatabase(const QString &path) // TODO make it a QMimeDatabase method?
|
||||
|
Loading…
Reference in New Issue
Block a user