summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@theqtcompany.com>2016-02-15 16:26:11 +0100
committerEike Ziller <eike.ziller@theqtcompany.com>2016-02-26 08:36:08 +0000
commit47c37556007041e4556b57da5cd73a736cc9b0ae (patch)
tree1cbee61c61407b166a6f170dbbdee9def438d2e0 /src
parentd2350c230eab4e7835268501b189ac5fde2563bc (diff)
downloadqt-creator-47c37556007041e4556b57da5cd73a736cc9b0ae.tar.gz
mapReduce: Support progress information and add (unordered) map
If a container is given to mapReduce, it takes the responsibility to report progress information for the whole operation. If the map function reports its own progress, that is taken into account for the overall progress. The (so far only unordered) Utils::map operation can be used to replace MultiTask, by passing a member function of the items in the container as a map function. Change-Id: I18ca38a6ad2899d73f590bfe59bf2e6eb2f1a57a Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/libs/utils/QtConcurrentTools1
-rw-r--r--src/libs/utils/filesearch.cpp4
-rw-r--r--src/libs/utils/mapreduce.h182
-rw-r--r--src/libs/utils/multitask.h196
-rw-r--r--src/libs/utils/utils-lib.pri1
-rw-r--r--src/libs/utils/utils.qbs1
-rw-r--r--src/plugins/autotest/testcodeparser.cpp2
-rw-r--r--src/plugins/autotest/testrunner.cpp2
-rw-r--r--src/plugins/coreplugin/locator/locator.cpp4
-rw-r--r--src/plugins/coreplugin/progressmanager/progressmanager.cpp4
10 files changed, 156 insertions, 241 deletions
diff --git a/src/libs/utils/QtConcurrentTools b/src/libs/utils/QtConcurrentTools
index 29eb543004..526becb684 100644
--- a/src/libs/utils/QtConcurrentTools
+++ b/src/libs/utils/QtConcurrentTools
@@ -23,5 +23,4 @@
**
****************************************************************************/
-#include "multitask.h"
#include "runextensions.h"
diff --git a/src/libs/utils/filesearch.cpp b/src/libs/utils/filesearch.cpp
index b5f28f0a72..1a13378d1c 100644
--- a/src/libs/utils/filesearch.cpp
+++ b/src/libs/utils/filesearch.cpp
@@ -359,7 +359,7 @@ void cleanUpFileSearch(QFutureInterface<FileSearchResultList> &futureInterface,
QFuture<FileSearchResultList> Utils::findInFiles(const QString &searchTerm, FileIterator *files,
QTextDocument::FindFlags flags, QMap<QString, QString> fileToContentsMap)
{
- return mapReduce(std::cref(*files),
+ return mapReduce(files->begin(), files->end(),
[searchTerm, files](QFutureInterface<FileSearchResultList> &futureInterface) {
return initFileSearch(futureInterface, searchTerm, files);
},
@@ -371,7 +371,7 @@ QFuture<FileSearchResultList> Utils::findInFiles(const QString &searchTerm, File
QFuture<FileSearchResultList> Utils::findInFilesRegExp(const QString &searchTerm, FileIterator *files,
QTextDocument::FindFlags flags, QMap<QString, QString> fileToContentsMap)
{
- return mapReduce(std::cref(*files),
+ return mapReduce(files->begin(), files->end(),
[searchTerm, files](QFutureInterface<FileSearchResultList> &futureInterface) {
return initFileSearch(futureInterface, searchTerm, files);
},
diff --git a/src/libs/utils/mapreduce.h b/src/libs/utils/mapreduce.h
index 6d26607619..1f103d64f6 100644
--- a/src/libs/utils/mapreduce.h
+++ b/src/libs/utils/mapreduce.h
@@ -25,6 +25,7 @@
#pragma once
+#include "utils_global.h"
#include "runextensions.h"
#include <QFutureWatcher>
@@ -32,31 +33,33 @@
namespace Utils {
namespace Internal {
-// TODO: try to use this for replacing MultiTask
-
-class MapReduceBase : public QObject
+class QTCREATOR_UTILS_EXPORT MapReduceObject : public QObject
{
Q_OBJECT
};
-template <typename Container, typename MapFunction, typename State, typename ReduceResult, typename ReduceFunction>
-class MapReduce : public MapReduceBase
+template <typename Iterator, typename MapResult, typename MapFunction, typename State, typename ReduceResult, typename ReduceFunction>
+class MapReduceBase : public MapReduceObject
{
- using MapResult = typename Internal::resultType<MapFunction>::type;
- using Iterator = typename Container::const_iterator;
+protected:
+ static const int MAX_PROGRESS = 1000000;
public:
- MapReduce(QFutureInterface<ReduceResult> futureInterface, const Container &container,
- const MapFunction &map, State &state, const ReduceFunction &reduce)
+ MapReduceBase(QFutureInterface<ReduceResult> futureInterface, Iterator begin, Iterator end,
+ const MapFunction &map, State &state, const ReduceFunction &reduce, int size)
: m_futureInterface(futureInterface),
- m_container(container),
- m_iterator(m_container.begin()),
+ m_iterator(begin),
+ m_end(end),
m_map(map),
m_state(state),
- m_reduce(reduce)
+ m_reduce(reduce),
+ m_handleProgress(size >= 0),
+ m_size(size)
{
+ if (m_handleProgress) // progress is handled by us
+ m_futureInterface.setProgressRange(0, MAX_PROGRESS);
connect(&m_selfWatcher, &QFutureWatcher<void>::canceled,
- this, &MapReduce::cancelAll);
+ this, &MapReduceBase::cancelAll);
m_selfWatcher.setFuture(futureInterface.future());
}
@@ -66,16 +69,24 @@ public:
m_loop.exec();
}
-private:
+protected:
+ virtual void reduce(QFutureWatcher<MapResult> *watcher) = 0;
+
bool schedule()
{
bool didSchedule = false;
- while (m_iterator != m_container.end() && m_mapWatcher.size() < QThread::idealThreadCount()) {
+ while (m_iterator != m_end && m_mapWatcher.size() < QThread::idealThreadCount()) {
didSchedule = true;
auto watcher = new QFutureWatcher<MapResult>();
connect(watcher, &QFutureWatcher<MapResult>::finished, this, [this, watcher]() {
mapFinished(watcher);
});
+ if (m_handleProgress) {
+ connect(watcher, &QFutureWatcher<MapResult>::progressValueChanged,
+ this, &MapReduceBase::updateProgress);
+ connect(watcher, &QFutureWatcher<MapResult>::progressRangeChanged,
+ this, &MapReduceBase::updateProgress);
+ }
m_mapWatcher.append(watcher);
watcher->setFuture(runAsync(&m_threadPool, m_map, *m_iterator));
++m_iterator;
@@ -85,22 +96,42 @@ private:
void mapFinished(QFutureWatcher<MapResult> *watcher)
{
- m_mapWatcher.removeAll(watcher); // remove so we can schedule next one
+ m_mapWatcher.removeOne(watcher); // remove so we can schedule next one
bool didSchedule = false;
if (!m_futureInterface.isCanceled()) {
// first schedule the next map...
didSchedule = schedule();
+ ++m_successfullyFinishedMapCount;
+ updateProgress();
// ...then reduce
- const int resultCount = watcher->future().resultCount();
- for (int i = 0; i < resultCount; ++i) {
- Internal::runAsyncImpl(m_futureInterface, m_reduce, m_state, watcher->future().resultAt(i));
- }
+ reduce(watcher);
}
delete watcher;
if (!didSchedule && m_mapWatcher.isEmpty())
m_loop.quit();
}
+ void updateProgress()
+ {
+ if (!m_handleProgress) // cannot compute progress
+ return;
+ if (m_size == 0 || m_successfullyFinishedMapCount == m_size) {
+ m_futureInterface.setProgressValue(MAX_PROGRESS);
+ return;
+ }
+ if (!m_futureInterface.isProgressUpdateNeeded())
+ return;
+ const double progressPerMap = MAX_PROGRESS / double(m_size);
+ double progress = m_successfullyFinishedMapCount * progressPerMap;
+ foreach (const QFutureWatcher<MapResult> *watcher, m_mapWatcher) {
+ if (watcher->progressMinimum() != watcher->progressMaximum()) {
+ const double range = watcher->progressMaximum() - watcher->progressMinimum();
+ progress += (watcher->progressValue() - watcher->progressMinimum()) / range * progressPerMap;
+ }
+ }
+ m_futureInterface.setProgressValue(int(progress));
+ }
+
void cancelAll()
{
foreach (QFutureWatcher<MapResult> *watcher, m_mapWatcher)
@@ -109,40 +140,110 @@ private:
QFutureWatcher<void> m_selfWatcher;
QFutureInterface<ReduceResult> m_futureInterface;
- const Container &m_container;
Iterator m_iterator;
+ const Iterator m_end;
const MapFunction &m_map;
State &m_state;
const ReduceFunction &m_reduce;
QEventLoop m_loop;
QThreadPool m_threadPool; // for reusing threads
QList<QFutureWatcher<MapResult> *> m_mapWatcher;
+ const bool m_handleProgress;
+ const int m_size;
+ int m_successfullyFinishedMapCount = 0;
};
-template <typename Container, typename InitFunction, typename MapFunction, typename ReduceResult,
+// non-void result of map function.
+template <typename Iterator, typename MapResult, typename MapFunction, typename State, typename ReduceResult, typename ReduceFunction>
+class MapReduce : public MapReduceBase<Iterator, MapResult, MapFunction, State, ReduceResult, ReduceFunction>
+{
+ using BaseType = MapReduceBase<Iterator, MapResult, MapFunction, State, ReduceResult, ReduceFunction>;
+public:
+ MapReduce(QFutureInterface<ReduceResult> futureInterface, Iterator begin, Iterator end,
+ const MapFunction &map, State &state, const ReduceFunction &reduce, int size)
+ : BaseType(futureInterface, begin, end, map, state, reduce, size)
+ {
+ }
+
+protected:
+ void reduce(QFutureWatcher<MapResult> *watcher) override
+ {
+ const int resultCount = watcher->future().resultCount();
+ for (int i = 0; i < resultCount; ++i) {
+ Internal::runAsyncImpl(BaseType::m_futureInterface, BaseType::m_reduce,
+ BaseType::m_state, watcher->future().resultAt(i));
+ }
+ }
+
+};
+
+// specialization for void result of map function. Reducing is a no-op.
+template <typename Iterator, typename MapFunction, typename State, typename ReduceResult, typename ReduceFunction>
+class MapReduce<Iterator, void, MapFunction, State, ReduceResult, ReduceFunction> : public MapReduceBase<Iterator, void, MapFunction, State, ReduceResult, ReduceFunction>
+{
+ using BaseType = MapReduceBase<Iterator, void, MapFunction, State, ReduceResult, ReduceFunction>;
+public:
+ MapReduce(QFutureInterface<ReduceResult> futureInterface, Iterator begin, Iterator end,
+ const MapFunction &map, State &state, const ReduceFunction &reduce, int size)
+ : BaseType(futureInterface, begin, end, map, state, reduce, size)
+ {
+ }
+
+protected:
+ void reduce(QFutureWatcher<void> *) override
+ {
+ }
+
+};
+
+template <typename Iterator, typename InitFunction, typename MapFunction, typename ReduceResult,
typename ReduceFunction, typename CleanUpFunction>
-void blockingMapReduce(QFutureInterface<ReduceResult> &futureInterface, const Container &container,
- const InitFunction &init, const MapFunction &map,
- const ReduceFunction &reduce, const CleanUpFunction &cleanup)
+void blockingIteratorMapReduce(QFutureInterface<ReduceResult> &futureInterface, Iterator begin, Iterator end,
+ const InitFunction &init, const MapFunction &map,
+ const ReduceFunction &reduce, const CleanUpFunction &cleanup, int size)
{
auto state = init(futureInterface);
- MapReduce<Container, MapFunction, decltype(state), ReduceResult, ReduceFunction> mr(futureInterface, container, map, state, reduce);
+ MapReduce<Iterator, typename Internal::resultType<MapFunction>::type, MapFunction, decltype(state), ReduceResult, ReduceFunction>
+ mr(futureInterface, begin, end, map, state, reduce, size);
mr.exec();
cleanup(futureInterface, state);
}
+template <typename Container, typename InitFunction, typename MapFunction, typename ReduceResult,
+ typename ReduceFunction, typename CleanUpFunction>
+void blockingContainerMapReduce(QFutureInterface<ReduceResult> &futureInterface, const Container &container,
+ const InitFunction &init, const MapFunction &map,
+ const ReduceFunction &reduce, const CleanUpFunction &cleanup)
+{
+ blockingIteratorMapReduce(futureInterface, std::begin(container), std::end(container),
+ init, map, reduce, cleanup, container.size());
+}
+
+template <typename ReduceResult>
+static void *dummyInit(QFutureInterface<ReduceResult> &) { return nullptr; }
+
+template <typename MapResult>
+struct DummyReduce {
+ MapResult operator()(void *, const MapResult &result) const { return result; }
+};
+template <>
+struct DummyReduce<void> {
+};
+
+template <typename ReduceResult>
+static void dummyCleanup(QFutureInterface<ReduceResult> &, void *) { }
+
} // Internal
-template <typename Container, typename InitFunction, typename MapFunction,
+template <typename Iterator, typename InitFunction, typename MapFunction,
typename ReduceFunction, typename CleanUpFunction,
typename ReduceResult = typename Internal::resultType<ReduceFunction>::type>
QFuture<ReduceResult>
-mapReduce(std::reference_wrapper<Container> containerWrapper,
- const InitFunction &init, const MapFunction &map,
- const ReduceFunction &reduce, const CleanUpFunction &cleanup)
+mapReduce(Iterator begin, Iterator end, const InitFunction &init, const MapFunction &map,
+ const ReduceFunction &reduce, const CleanUpFunction &cleanup, int size = -1)
{
- return runAsync(Internal::blockingMapReduce<Container, InitFunction, MapFunction, ReduceResult, ReduceFunction, CleanUpFunction>,
- containerWrapper, init, map, reduce, cleanup);
+ return runAsync(Internal::blockingIteratorMapReduce<Iterator, InitFunction, MapFunction, ReduceResult, ReduceFunction, CleanUpFunction>,
+ begin, end, init, map, reduce, cleanup, size);
}
/*!
@@ -184,8 +285,21 @@ QFuture<ReduceResult>
mapReduce(const Container &container, const InitFunction &init, const MapFunction &map,
const ReduceFunction &reduce, const CleanUpFunction &cleanup)
{
- return runAsync(Internal::blockingMapReduce<Container, InitFunction, MapFunction, ReduceResult, ReduceFunction, CleanUpFunction>,
- container, init, map, reduce, cleanup);
+ return runAsync(Internal::blockingContainerMapReduce<Container, InitFunction, MapFunction, ReduceResult, ReduceFunction, CleanUpFunction>,
+ container, init, map, reduce, cleanup);
+}
+
+// TODO: Currently does not order its map results.
+template <typename Container, typename MapFunction,
+ typename MapResult = typename Internal::resultType<MapFunction>::type>
+QFuture<MapResult>
+map(const Container &container, const MapFunction &map)
+{
+ return mapReduce(container,
+ &Internal::dummyInit<MapResult>,
+ map,
+ Internal::DummyReduce<MapResult>(),
+ &Internal::dummyCleanup<MapResult>);
}
} // Utils
diff --git a/src/libs/utils/multitask.h b/src/libs/utils/multitask.h
deleted file mode 100644
index 2773eb2aaf..0000000000
--- a/src/libs/utils/multitask.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#ifndef MULTITASK_H
-#define MULTITASK_H
-
-#include "utils_global.h"
-#include "runextensions.h"
-
-#include <QObject>
-#include <QList>
-#include <QEventLoop>
-#include <QFutureWatcher>
-#include <QtConcurrentRun>
-#include <QThreadPool>
-
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-namespace QtConcurrent {
-
-class QTCREATOR_UTILS_EXPORT MultiTaskBase : public QObject, public QRunnable
-{
- Q_OBJECT
-protected slots:
- virtual void cancelSelf() = 0;
- virtual void setFinished() = 0;
- virtual void setProgressRange(int min, int max) = 0;
- virtual void setProgressValue(int value) = 0;
- virtual void setProgressText(QString value) = 0;
-};
-
-template <typename Class, typename R>
-class MultiTask : public MultiTaskBase
-{
-public:
- MultiTask(void (Class::*fn)(QFutureInterface<R> &), const QList<Class *> &objects)
- : fn(fn),
- objects(objects)
- {
- maxProgress = 100*objects.size();
- }
-
- QFuture<R> future()
- {
- futureInterface.reportStarted();
- return futureInterface.future();
- }
-
- void run()
- {
- QThreadPool::globalInstance()->releaseThread();
- futureInterface.setProgressRange(0, maxProgress);
- foreach (Class *object, objects) {
- QFutureWatcher<R> *watcher = new QFutureWatcher<R>();
- watchers.insert(object, watcher);
- finished.insert(watcher, false);
- connect(watcher, &QFutureWatcherBase::finished,
- this, &MultiTask::setFinished);
- connect(watcher, &QFutureWatcherBase::progressRangeChanged,
- this, &MultiTask::setProgressRange);
- connect(watcher, &QFutureWatcherBase::progressValueChanged,
- this, &MultiTask::setProgressValue);
- connect(watcher, &QFutureWatcherBase::progressTextChanged,
- this, &MultiTask::setProgressText);
- watcher->setFuture(Utils::runAsync(QThreadPool::globalInstance(), fn, object));
- }
- selfWatcher = new QFutureWatcher<R>();
- connect(selfWatcher, &QFutureWatcherBase::canceled, this, &MultiTask::cancelSelf);
- selfWatcher->setFuture(futureInterface.future());
- loop = new QEventLoop;
- loop->exec();
- futureInterface.reportFinished();
- QThreadPool::globalInstance()->reserveThread();
- qDeleteAll(watchers);
- delete selfWatcher;
- delete loop;
- }
-protected:
- void cancelSelf()
- {
- foreach (QFutureWatcher<R> *watcher, watchers)
- watcher->future().cancel();
- }
-
- void setFinished()
- {
- updateProgress();
- QFutureWatcher<R> *watcher = static_cast<QFutureWatcher<R> *>(sender());
- if (finished.contains(watcher))
- finished[watcher] = true;
- bool allFinished = true;
- foreach (bool isFinished, finished) {
- if (!isFinished) {
- allFinished = false;
- break;
- }
- }
- if (allFinished)
- loop->quit();
- }
-
- void setProgressRange(int min, int max)
- {
- Q_UNUSED(min)
- Q_UNUSED(max)
- updateProgress();
- }
-
- void setProgressValue(int value)
- {
- Q_UNUSED(value)
- updateProgress();
- }
-
- void setProgressText(QString value)
- {
- Q_UNUSED(value)
- updateProgressText();
- }
-private:
- void updateProgress()
- {
- int progressSum = 0;
- foreach (QFutureWatcher<R> *watcher, watchers) {
- if (watcher->progressMinimum() == watcher->progressMaximum()) {
- if (watcher->future().isFinished() && !watcher->future().isCanceled())
- progressSum += 100;
- } else {
- progressSum += 100*(watcher->progressValue()-watcher->progressMinimum())/(watcher->progressMaximum()-watcher->progressMinimum());
- }
- }
- futureInterface.setProgressValue(progressSum);
- }
-
- void updateProgressText()
- {
- QString text;
- foreach (QFutureWatcher<R> *watcher, watchers) {
- if (!watcher->progressText().isEmpty()) {
- text += watcher->progressText();
- text += QLatin1Char('\n');
- }
- }
- text = text.trimmed();
- futureInterface.setProgressValueAndText(futureInterface.progressValue(), text);
- }
-
- QFutureInterface<R> futureInterface;
- void (Class::*fn)(QFutureInterface<R> &);
- QList<Class *> objects;
-
- QFutureWatcher<R> *selfWatcher;
- QMap<Class *, QFutureWatcher<R> *> watchers;
- QMap<QFutureWatcher<R> *, bool> finished;
- QEventLoop *loop;
- int maxProgress;
-};
-
-template <typename Class, typename T>
-QFuture<T> run(void (Class::*fn)(QFutureInterface<T> &), const QList<Class *> &objects, int priority = 0)
-{
- MultiTask<Class, T> *task = new MultiTask<Class, T>(fn, objects);
- QFuture<T> future = task->future();
- QThreadPool::globalInstance()->start(task, priority);
- return future;
-}
-
-} // namespace QtConcurrent
-
-QT_END_NAMESPACE
-
-#endif // MULTITASK_H
diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri
index c952b2ebef..476714a887 100644
--- a/src/libs/utils/utils-lib.pri
+++ b/src/libs/utils/utils-lib.pri
@@ -168,7 +168,6 @@ HEADERS += \
$$PWD/persistentsettings.h \
$$PWD/completingtextedit.h \
$$PWD/json.h \
- $$PWD/multitask.h \
$$PWD/runextensions.h \
$$PWD/portlist.h \
$$PWD/tcpportsgatherer.h \
diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs
index 7f69e1a0d8..5f7af98765 100644
--- a/src/libs/utils/utils.qbs
+++ b/src/libs/utils/utils.qbs
@@ -124,7 +124,6 @@ QtcLibrary {
"macroexpander.cpp",
"macroexpander.h",
"mapreduce.h",
- "multitask.h",
"navigationtreeview.cpp",
"navigationtreeview.h",
"networkaccessmanager.cpp",
diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp
index 8d6cc68a2f..e9ecc29726 100644
--- a/src/plugins/autotest/testcodeparser.cpp
+++ b/src/plugins/autotest/testcodeparser.cpp
@@ -46,8 +46,8 @@
#include <qmljs/qmljsdialect.h>
#include <qmljstools/qmljsmodelmanager.h>
-#include <utils/multitask.h>
#include <utils/qtcassert.h>
+#include <utils/runextensions.h>
#include <utils/textfileformat.h>
#include <QDirIterator>
diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp
index 2bece16b65..b61413336b 100644
--- a/src/plugins/autotest/testrunner.cpp
+++ b/src/plugins/autotest/testrunner.cpp
@@ -39,7 +39,7 @@
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorersettings.h>
-#include <utils/multitask.h>
+#include <utils/runextensions.h>
#include <QFuture>
#include <QFutureInterface>
diff --git a/src/plugins/coreplugin/locator/locator.cpp b/src/plugins/coreplugin/locator/locator.cpp
index 04ec66bb2e..d9c8f56bdf 100644
--- a/src/plugins/coreplugin/locator/locator.cpp
+++ b/src/plugins/coreplugin/locator/locator.cpp
@@ -46,7 +46,7 @@
#include <coreplugin/progressmanager/futureprogress.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/algorithm.h>
-#include <utils/QtConcurrentTools>
+#include <utils/mapreduce.h>
#include <utils/qtcassert.h>
#include <QSettings>
@@ -312,7 +312,7 @@ void Locator::refresh(QList<ILocatorFilter *> filters)
{
if (filters.isEmpty())
filters = m_filters;
- QFuture<void> task = QtConcurrent::run(&ILocatorFilter::refresh, filters);
+ QFuture<void> task = Utils::map(filters, &ILocatorFilter::refresh);
FutureProgress *progress =
ProgressManager::addTask(task, tr("Updating Locator Caches"), Constants::TASK_INDEX);
connect(progress, &FutureProgress::finished, this, &Locator::saveSettings);
diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp
index c22e3177d4..885463db0d 100644
--- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp
+++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp
@@ -150,11 +150,11 @@ using namespace Utils;
The actual refresh, which calls all the filters' refresh functions
in a different thread, looks like this:
\code
- QFuture<void> task = QtConcurrent::run(&ILocatorFilter::refresh, filters);
+ QFuture<void> task = Utils::map(filters, &ILocatorFilter::refresh);
Core::FutureProgress *progress = Core::ProgressManager::addTask(task, tr("Indexing"),
Locator::Constants::TASK_INDEX);
\endcode
- First, we tell QtConcurrent to start a thread which calls all the filters'
+ First, we to start an asynchronous operation which calls all the filters'
refresh function. After that we register the returned QFuture object
with the ProgressManager.