diff --git a/src/libs/utils/asynctask.h b/src/libs/utils/asynctask.h index d7c51a66fae..07b38487495 100644 --- a/src/libs/utils/asynctask.h +++ b/src/libs/utils/asynctask.h @@ -115,7 +115,7 @@ const QFuture &onFinished(const QFuture &future, QObject *guard, Function return future; } -class QTCREATOR_UTILS_EXPORT AsyncTaskBase : public QObject +class QTCREATOR_UTILS_EXPORT AsyncBase : public QObject { Q_OBJECT @@ -126,15 +126,14 @@ signals: }; template -class AsyncTask : public AsyncTaskBase +class Async : public AsyncBase { public: - AsyncTask() { - connect(&m_watcher, &QFutureWatcherBase::finished, this, &AsyncTaskBase::done); - connect(&m_watcher, &QFutureWatcherBase::resultReadyAt, - this, &AsyncTaskBase::resultReadyAt); + Async() { + connect(&m_watcher, &QFutureWatcherBase::finished, this, &AsyncBase::done); + connect(&m_watcher, &QFutureWatcherBase::resultReadyAt, this, &AsyncBase::resultReadyAt); } - ~AsyncTask() + ~Async() { if (isDone()) return; @@ -199,11 +198,11 @@ private: }; template -class AsyncTaskAdapter : public Tasking::TaskAdapter> +class AsyncTaskAdapter : public Tasking::TaskAdapter> { public: AsyncTaskAdapter() { - this->connect(this->task(), &AsyncTaskBase::done, this, [this] { + this->connect(this->task(), &AsyncBase::done, this, [this] { emit this->done(!this->task()->isCanceled()); }); } @@ -212,4 +211,4 @@ public: } // namespace Utils -QTC_DECLARE_CUSTOM_TEMPLATE_TASK(Async, AsyncTaskAdapter); +QTC_DECLARE_CUSTOM_TEMPLATE_TASK(AsyncTask, AsyncTaskAdapter); diff --git a/src/libs/utils/filestreamer.cpp b/src/libs/utils/filestreamer.cpp index a6a3e76ae62..cdc192422a9 100644 --- a/src/libs/utils/filestreamer.cpp +++ b/src/libs/utils/filestreamer.cpp @@ -96,14 +96,14 @@ private: return ProcessTask(setup); } TaskItem localTask() final { - const auto setup = [this](AsyncTask &async) { + const auto setup = [this](Async &async) { async.setConcurrentCallData(localRead, m_filePath); - AsyncTask *asyncPtr = &async; - connect(asyncPtr, &AsyncTaskBase::resultReadyAt, this, [=](int index) { + Async *asyncPtr = &async; + connect(asyncPtr, &AsyncBase::resultReadyAt, this, [=](int index) { emit readyRead(asyncPtr->resultAt(index)); }); }; - return Async(setup); + return AsyncTask(setup); } }; @@ -267,16 +267,16 @@ private: return ProcessTask(setup, finalize, finalize); } TaskItem localTask() final { - const auto setup = [this](AsyncTask &async) { + const auto setup = [this](Async &async) { m_writeBuffer = new WriteBuffer(isBuffered(), &async); async.setConcurrentCallData(localWrite, m_filePath, m_writeData, m_writeBuffer); emit started(); }; - const auto finalize = [this](const AsyncTask &) { + const auto finalize = [this](const Async &) { delete m_writeBuffer; m_writeBuffer = nullptr; }; - return Async(setup, finalize, finalize); + return AsyncTask(setup, finalize, finalize); } bool isBuffered() const { return m_writeData.isEmpty(); } @@ -437,10 +437,10 @@ private: return Writer(setup); } TaskItem transferTask() { - const auto setup = [this](AsyncTask &async) { + const auto setup = [this](Async &async) { async.setConcurrentCallData(transfer, m_source, m_destination); }; - return Async(setup); + return AsyncTask(setup); } }; diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index b6a87c20383..b6b6eaea01e 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -361,17 +361,17 @@ void TestCodeParser::scanForTests(const QSet &filePaths, QList tasks{ParallelLimit(std::max(QThread::idealThreadCount() / 4, 1))}; for (const FilePath &file : filteredFiles) { - const auto setup = [this, codeParsers, file](AsyncTask &async) { + const auto setup = [this, codeParsers, file](Async &async) { async.setConcurrentCallData(parseFileForTests, codeParsers, file); async.setPriority(QThread::LowestPriority); async.setFutureSynchronizer(&m_futureSynchronizer); }; - const auto onDone = [this](const AsyncTask &async) { + const auto onDone = [this](const Async &async) { const QList results = async.results(); for (const TestParseResultPtr &result : results) emit testParseResultReady(result); }; - tasks.append(Async(setup, onDone)); + tasks.append(AsyncTask(setup, onDone)); } m_taskTree.reset(new TaskTree{tasks}); const auto onDone = [this] { m_taskTree.release()->deleteLater(); onFinished(true); }; diff --git a/src/plugins/clangcodemodel/clangdlocatorfilters.cpp b/src/plugins/clangcodemodel/clangdlocatorfilters.cpp index 1f4db567def..4dd0b3b9994 100644 --- a/src/plugins/clangcodemodel/clangdlocatorfilters.cpp +++ b/src/plugins/clangcodemodel/clangdlocatorfilters.cpp @@ -443,7 +443,7 @@ LocatorMatcherTask currentDocumentMatcher() *resultStorage = request.currentDocumentSymbolsData(); }; - const auto onFilterSetup = [=](AsyncTask &async) { + const auto onFilterSetup = [=](Async &async) { async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setConcurrentCallData(filterCurrentResults, *storage, *resultStorage, TextDocument::currentTextDocument()->plainText()); @@ -452,7 +452,7 @@ LocatorMatcherTask currentDocumentMatcher() const Group root { Storage(resultStorage), CurrentDocumentSymbolsRequest(onQuerySetup, onQueryDone), - Async(onFilterSetup) + AsyncTask(onFilterSetup) }; return {root, storage}; } diff --git a/src/plugins/coreplugin/actionsfilter.cpp b/src/plugins/coreplugin/actionsfilter.cpp index 6930e6af018..3d04766c93b 100644 --- a/src/plugins/coreplugin/actionsfilter.cpp +++ b/src/plugins/coreplugin/actionsfilter.cpp @@ -180,7 +180,7 @@ LocatorMatcherTasks ActionsFilter::matchers() TreeStorage storage; - const auto onSetup = [this, storage](AsyncTask &async) { + const auto onSetup = [this, storage](Async &async) { m_entries.clear(); m_indexes.clear(); QList processedMenus; @@ -197,7 +197,7 @@ LocatorMatcherTasks ActionsFilter::matchers() return TaskAction::Continue; }; - return {{Async(onSetup), storage}}; + return {{AsyncTask(onSetup), storage}}; } diff --git a/src/plugins/coreplugin/locator/directoryfilter.cpp b/src/plugins/coreplugin/locator/directoryfilter.cpp index 26a9455ca57..2b09b295425 100644 --- a/src/plugins/coreplugin/locator/directoryfilter.cpp +++ b/src/plugins/coreplugin/locator/directoryfilter.cpp @@ -87,17 +87,17 @@ DirectoryFilter::DirectoryFilter(Id id) updateFileIterator(); return TaskAction::StopWithDone; // Group stops, skips async task }; - const auto asyncSetup = [this](AsyncTask &async) { + const auto asyncSetup = [this](Async &async) { async.setConcurrentCallData(&refresh, m_directories, m_filters, m_exclusionFilters, displayName()); }; - const auto asyncDone = [this](const AsyncTask &async) { + const auto asyncDone = [this](const Async &async) { m_files = async.isResultAvailable() ? async.result() : FilePaths(); updateFileIterator(); }; const Group root { OnGroupSetup(groupSetup), - Async(asyncSetup, asyncDone) + AsyncTask(asyncSetup, asyncDone) }; setRefreshRecipe(root); } diff --git a/src/plugins/coreplugin/locator/filesystemfilter.cpp b/src/plugins/coreplugin/locator/filesystemfilter.cpp index 4f3f349bcdc..5bd2d1a155a 100644 --- a/src/plugins/coreplugin/locator/filesystemfilter.cpp +++ b/src/plugins/coreplugin/locator/filesystemfilter.cpp @@ -323,7 +323,7 @@ LocatorMatcherTasks FileSystemFilter::matchers() TreeStorage storage; - const auto onSetup = [this, storage](AsyncTask &async) { + const auto onSetup = [this, storage](Async &async) { async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setConcurrentCallData(matches, *storage, @@ -332,7 +332,7 @@ LocatorMatcherTasks FileSystemFilter::matchers() m_includeHidden); }; - return {{Async(onSetup), storage}}; + return {{AsyncTask(onSetup), storage}}; } void FileSystemFilter::prepareSearch(const QString &entry) diff --git a/src/plugins/coreplugin/locator/ilocatorfilter.cpp b/src/plugins/coreplugin/locator/ilocatorfilter.cpp index b4809d897c7..70c70bbd963 100644 --- a/src/plugins/coreplugin/locator/ilocatorfilter.cpp +++ b/src/plugins/coreplugin/locator/ilocatorfilter.cpp @@ -1529,7 +1529,7 @@ LocatorMatcherTask LocatorFileCache::matcher() const TreeStorage storage; std::weak_ptr weak = d; - const auto onSetup = [storage, weak](AsyncTask &async) { + const auto onSetup = [storage, weak](Async &async) { auto that = weak.lock(); if (!that) // LocatorMatcher is running after *this LocatorFileCache was destructed. return TaskAction::StopWithDone; @@ -1543,7 +1543,7 @@ LocatorMatcherTask LocatorFileCache::matcher() const async.setConcurrentCallData(&filter, *storage, *that); return TaskAction::Continue; }; - const auto onDone = [weak](const AsyncTask &async) { + const auto onDone = [weak](const Async &async) { auto that = weak.lock(); if (!that) return; // LocatorMatcherTask finished after *this LocatorFileCache was destructed. @@ -1560,7 +1560,7 @@ LocatorMatcherTask LocatorFileCache::matcher() const that->update(async.result()); }; - return {Async(onSetup, onDone), storage}; + return {AsyncTask(onSetup, onDone), storage}; } } // Core diff --git a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp index 2fd479568ab..7cf3b986e8c 100644 --- a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp +++ b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp @@ -79,14 +79,14 @@ LocatorMatcherTasks OpenDocumentsFilter::matchers() TreeStorage storage; - const auto onSetup = [storage](AsyncTask &async) { + const auto onSetup = [storage](Async &async) { const QList editorsData = Utils::transform(DocumentModel::entries(), [](const DocumentModel::Entry *e) { return Entry{e->filePath(), e->displayName()}; }); async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setConcurrentCallData(matchEditors, *storage, editorsData); }; - return {{Async(onSetup), storage}}; + return {{AsyncTask(onSetup), storage}}; } void OpenDocumentsFilter::slotDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, diff --git a/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp b/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp index f22cfd5c11e..1d57a0aed7c 100644 --- a/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp +++ b/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp @@ -299,7 +299,7 @@ LocatorMatcherTasks SpotlightLocatorFilter::matchers() TreeStorage storage; const auto onSetup = [storage, command = m_command, insensArgs = m_arguments, - sensArgs = m_caseSensitiveArguments](AsyncTask &async) { + sensArgs = m_caseSensitiveArguments](Async &async) { const Link link = Link::fromString(storage->input(), true); const FilePath input = link.targetFilePath; if (input.isEmpty()) @@ -316,7 +316,7 @@ LocatorMatcherTasks SpotlightLocatorFilter::matchers() return TaskAction::Continue; }; - return {{Async(onSetup), storage}}; + return {{AsyncTask(onSetup), storage}}; } void SpotlightLocatorFilter::prepareSearch(const QString &entry) diff --git a/src/plugins/cppeditor/cpplocatorfilter.cpp b/src/plugins/cppeditor/cpplocatorfilter.cpp index c13948bb3e9..c257444ce12 100644 --- a/src/plugins/cppeditor/cpplocatorfilter.cpp +++ b/src/plugins/cppeditor/cpplocatorfilter.cpp @@ -108,11 +108,11 @@ LocatorMatcherTask locatorMatcher(IndexItem::ItemType type, const EntryFromIndex TreeStorage storage; - const auto onSetup = [=](AsyncTask &async) { + const auto onSetup = [=](Async &async) { async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setConcurrentCallData(matchesFor, *storage, type, converter); }; - return {Async(onSetup), storage}; + return {AsyncTask(onSetup), storage}; } LocatorMatcherTask allSymbolsMatcher() @@ -304,11 +304,11 @@ LocatorMatcherTask currentDocumentMatcher() TreeStorage storage; - const auto onSetup = [=](AsyncTask &async) { + const auto onSetup = [=](Async &async) { async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setConcurrentCallData(matchesForCurrentDocument, *storage, currentFileName()); }; - return {Async(onSetup), storage}; + return {AsyncTask(onSetup), storage}; } using MatcherCreator = std::function; diff --git a/src/plugins/cppeditor/cppprojectupdater.cpp b/src/plugins/cppeditor/cppprojectupdater.cpp index 6bab2ec3c3c..dbea7361df9 100644 --- a/src/plugins/cppeditor/cppprojectupdater.cpp +++ b/src/plugins/cppeditor/cppprojectupdater.cpp @@ -58,16 +58,16 @@ void CppProjectUpdater::update(const ProjectUpdateInfo &projectUpdateInfo, ProjectInfo::ConstPtr projectInfo = nullptr; }; const TreeStorage storage; - const auto setupInfoGenerator = [=](AsyncTask &async) { + const auto setupInfoGenerator = [=](Async &async) { async.setConcurrentCallData(infoGenerator); async.setFutureSynchronizer(&m_futureSynchronizer); }; - const auto onInfoGeneratorDone = [=](const AsyncTask &async) { + const auto onInfoGeneratorDone = [=](const Async &async) { if (async.isResultAvailable()) storage->projectInfo = async.result(); }; QList tasks{parallel}; - tasks.append(Async(setupInfoGenerator, onInfoGeneratorDone)); + tasks.append(AsyncTask(setupInfoGenerator, onInfoGeneratorDone)); for (QPointer compiler : compilers) { if (compiler && compiler->isDirty()) tasks.append(compiler->compileFileItem()); diff --git a/src/plugins/debugger/loadcoredialog.cpp b/src/plugins/debugger/loadcoredialog.cpp index 85a81a9418d..e481aef4b78 100644 --- a/src/plugins/debugger/loadcoredialog.cpp +++ b/src/plugins/debugger/loadcoredialog.cpp @@ -249,11 +249,11 @@ void AttachCoreDialog::accepted() const Group root = { parallel, - Async{[=](auto &task) { + AsyncTask{[=](auto &task) { task.setConcurrentCallData(copyFileAsync, this->coreFile()); }, [=](const auto &task) { d->coreFileResult = task.result(); }}, - Async{[=](auto &task) { + AsyncTask{[=](auto &task) { task.setConcurrentCallData(copyFileAsync, this->symbolFile()); }, [=](const auto &task) { d->symbolFileResult = task.result(); }}, diff --git a/src/plugins/diffeditor/diffeditorplugin.cpp b/src/plugins/diffeditor/diffeditorplugin.cpp index eed5a6d0e4a..07410aee6f3 100644 --- a/src/plugins/diffeditor/diffeditorplugin.cpp +++ b/src/plugins/diffeditor/diffeditorplugin.cpp @@ -114,12 +114,12 @@ DiffFilesController::DiffFilesController(IDocument *document) const auto setupTree = [this, storage](TaskTree &taskTree) { QList> *outputList = storage.activeStorage(); - const auto setupDiff = [this](AsyncTask &async, const ReloadInput &reloadInput) { + const auto setupDiff = [this](Async &async, const ReloadInput &reloadInput) { async.setConcurrentCallData( DiffFile(ignoreWhitespace(), contextLineCount()), reloadInput); async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); }; - const auto onDiffDone = [outputList](const AsyncTask &async, int i) { + const auto onDiffDone = [outputList](const Async &async, int i) { if (async.isResultAvailable()) (*outputList)[i] = async.result(); }; @@ -130,7 +130,7 @@ DiffFilesController::DiffFilesController(IDocument *document) using namespace std::placeholders; QList tasks {parallel, optional}; for (int i = 0; i < inputList.size(); ++i) { - tasks.append(Async(std::bind(setupDiff, _1, inputList.at(i)), + tasks.append(AsyncTask(std::bind(setupDiff, _1, inputList.at(i)), std::bind(onDiffDone, _1, i))); } taskTree.setupRoot(tasks); diff --git a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp index f1467f6ea27..8a69550232f 100644 --- a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp +++ b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp @@ -869,11 +869,11 @@ void SideBySideDiffEditorWidget::restoreState() void SideBySideDiffEditorWidget::showDiff() { - m_asyncTask.reset(new AsyncTask()); + m_asyncTask.reset(new Async()); m_asyncTask->setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); m_controller.setBusyShowing(true); - connect(m_asyncTask.get(), &AsyncTaskBase::done, this, [this] { + connect(m_asyncTask.get(), &AsyncBase::done, this, [this] { if (m_asyncTask->isCanceled() || !m_asyncTask->isResultAvailable()) { for (SideDiffEditorWidget *editor : m_editor) editor->clearAll(Tr::tr("Retrieving data failed.")); diff --git a/src/plugins/diffeditor/sidebysidediffeditorwidget.h b/src/plugins/diffeditor/sidebysidediffeditorwidget.h index c12025a6c00..f164d865798 100644 --- a/src/plugins/diffeditor/sidebysidediffeditorwidget.h +++ b/src/plugins/diffeditor/sidebysidediffeditorwidget.h @@ -18,7 +18,7 @@ class TextEditorWidget; namespace Utils { template -class AsyncTask; +class Async; } QT_BEGIN_NAMESPACE @@ -141,7 +141,7 @@ private: bool m_horizontalSync = false; - std::unique_ptr> m_asyncTask; + std::unique_ptr> m_asyncTask; }; } // namespace Internal diff --git a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp index d914ef59cb5..43d9f4c749d 100644 --- a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp +++ b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp @@ -452,10 +452,10 @@ void UnifiedDiffEditorWidget::showDiff() return; } - m_asyncTask.reset(new AsyncTask()); + m_asyncTask.reset(new Async()); m_asyncTask->setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); m_controller.setBusyShowing(true); - connect(m_asyncTask.get(), &AsyncTaskBase::done, this, [this] { + connect(m_asyncTask.get(), &AsyncBase::done, this, [this] { if (m_asyncTask->isCanceled() || !m_asyncTask->isResultAvailable()) { setPlainText(Tr::tr("Retrieving data failed.")); } else { diff --git a/src/plugins/diffeditor/unifieddiffeditorwidget.h b/src/plugins/diffeditor/unifieddiffeditorwidget.h index cbad273ab2f..ae7060b1446 100644 --- a/src/plugins/diffeditor/unifieddiffeditorwidget.h +++ b/src/plugins/diffeditor/unifieddiffeditorwidget.h @@ -12,7 +12,7 @@ namespace TextEditor { class FontSettings; } namespace Utils { template -class AsyncTask; +class Async; } QT_BEGIN_NAMESPACE @@ -112,7 +112,7 @@ private: DiffEditorWidgetController m_controller; QByteArray m_state; - std::unique_ptr> m_asyncTask; + std::unique_ptr> m_asyncTask; }; } // namespace Internal diff --git a/src/plugins/help/helpindexfilter.cpp b/src/plugins/help/helpindexfilter.cpp index a55cf0e6504..0556e970ac8 100644 --- a/src/plugins/help/helpindexfilter.cpp +++ b/src/plugins/help/helpindexfilter.cpp @@ -87,7 +87,7 @@ LocatorMatcherTasks HelpIndexFilter::matchers() TreeStorage storage; - const auto onSetup = [this, storage](AsyncTask &async) { + const auto onSetup = [this, storage](Async &async) { if (m_needsUpdate) { m_needsUpdate = false; LocalHelpManager::setupGuiHelpEngine(); @@ -100,14 +100,14 @@ LocatorMatcherTasks HelpIndexFilter::matchers() async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setConcurrentCallData(matches, *storage, cache, m_icon); }; - const auto onDone = [this, storage](const AsyncTask &async) { + const auto onDone = [this, storage](const Async &async) { if (async.isResultAvailable()) { m_lastIndicesCache = async.result(); m_lastEntry = storage->input(); } }; - return {{Async(onSetup, onDone), storage}}; + return {{AsyncTask(onSetup, onDone), storage}}; } void HelpIndexFilter::prepareSearch(const QString &entry) diff --git a/src/plugins/languageclient/locatorfilter.cpp b/src/plugins/languageclient/locatorfilter.cpp index 16c0d52c72d..158d7476dbb 100644 --- a/src/plugins/languageclient/locatorfilter.cpp +++ b/src/plugins/languageclient/locatorfilter.cpp @@ -75,7 +75,7 @@ LocatorMatcherTask locatorMatcher(Client *client, int maxResultCount, *resultStorage = result->toList(); }; - const auto onFilterSetup = [=](AsyncTask &async) { + const auto onFilterSetup = [=](Async &async) { const QList results = *resultStorage; if (results.isEmpty()) return TaskAction::StopWithDone; @@ -87,7 +87,7 @@ LocatorMatcherTask locatorMatcher(Client *client, int maxResultCount, const Group root { Storage(resultStorage), SymbolRequest(onQuerySetup, onQueryDone), - Async(onFilterSetup) + AsyncTask(onFilterSetup) }; return {root, storage}; } @@ -138,7 +138,7 @@ LocatorMatcherTask currentDocumentMatcher() *resultStorage = request.currentDocumentSymbolsData(); }; - const auto onFilterSetup = [=](AsyncTask &async) { + const auto onFilterSetup = [=](Async &async) { async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setConcurrentCallData(filterCurrentResults, *storage, *resultStorage); }; @@ -146,7 +146,7 @@ LocatorMatcherTask currentDocumentMatcher() const Group root { Storage(resultStorage), CurrentDocumentSymbolsRequest(onQuerySetup, onQueryDone), - Async(onFilterSetup) + AsyncTask(onFilterSetup) }; return {root, storage}; } diff --git a/src/plugins/projectexplorer/extracompiler.cpp b/src/plugins/projectexplorer/extracompiler.cpp index 0f0953cb3e7..291493bcbfc 100644 --- a/src/plugins/projectexplorer/extracompiler.cpp +++ b/src/plugins/projectexplorer/extracompiler.cpp @@ -327,14 +327,14 @@ ProcessExtraCompiler::ProcessExtraCompiler(const Project *project, const FilePat Tasking::TaskItem ProcessExtraCompiler::taskItemImpl(const ContentProvider &provider) { - const auto setupTask = [=](AsyncTask &async) { + const auto setupTask = [=](Async &async) { async.setThreadPool(extraCompilerThreadPool()); // The passed synchronizer has cancelOnWait set to true by default. async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setConcurrentCallData(&ProcessExtraCompiler::runInThread, this, command(), workingDirectory(), arguments(), provider, buildEnvironment()); }; - const auto taskDone = [=](const AsyncTask &async) { + const auto taskDone = [=](const Async &async) { if (!async.isResultAvailable()) return; const FileNameToContentsHash data = async.result(); @@ -344,7 +344,7 @@ Tasking::TaskItem ProcessExtraCompiler::taskItemImpl(const ContentProvider &prov setContent(it.key(), it.value()); updateCompileTime(); }; - return Tasking::Async(setupTask, taskDone); + return Tasking::AsyncTask(setupTask, taskDone); } FilePath ProcessExtraCompiler::workingDirectory() const diff --git a/src/plugins/qmljstools/qmljsfunctionfilter.cpp b/src/plugins/qmljstools/qmljsfunctionfilter.cpp index d24b02156ba..ac173e515d1 100644 --- a/src/plugins/qmljstools/qmljsfunctionfilter.cpp +++ b/src/plugins/qmljstools/qmljsfunctionfilter.cpp @@ -82,12 +82,12 @@ LocatorMatcherTasks FunctionFilter::matchers() TreeStorage storage; - const auto onSetup = [storage, entries = m_data->entries()](AsyncTask &async) { + const auto onSetup = [storage, entries = m_data->entries()](Async &async) { async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setConcurrentCallData(matches, *storage, entries); }; - return {{Async(onSetup), storage}}; + return {{AsyncTask(onSetup), storage}}; } QList FunctionFilter::matchesFor(QFutureInterface &future, diff --git a/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp b/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp index 0735fee7296..e52fbb47c9f 100644 --- a/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp +++ b/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp @@ -48,7 +48,7 @@ Tasking::TaskItem VcsBaseDiffEditorController::postProcessTask() { using namespace Tasking; - const auto setupDiffProcessor = [this](AsyncTask> &async) { + const auto setupDiffProcessor = [this](Async> &async) { const QString *storage = inputStorage().activeStorage(); QTC_ASSERT(storage, qWarning("Using postProcessTask() requires putting inputStorage() " "into task tree's root group.")); @@ -56,14 +56,14 @@ Tasking::TaskItem VcsBaseDiffEditorController::postProcessTask() async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setConcurrentCallData(&DiffUtils::readPatchWithPromise, inputData); }; - const auto onDiffProcessorDone = [this](const AsyncTask> &async) { + const auto onDiffProcessorDone = [this](const Async> &async) { setDiffFiles(async.isResultAvailable() ? async.result() : QList()); // TODO: We should set the right starting line here }; - const auto onDiffProcessorError = [this](const AsyncTask> &) { + const auto onDiffProcessorError = [this](const Async> &) { setDiffFiles({}); }; - return Async>(setupDiffProcessor, onDiffProcessorDone, onDiffProcessorError); + return AsyncTask>(setupDiffProcessor, onDiffProcessorDone, onDiffProcessorError); } void VcsBaseDiffEditorController::setupCommand(QtcProcess &process, const QStringList &args) const diff --git a/tests/auto/utils/asynctask/tst_asynctask.cpp b/tests/auto/utils/asynctask/tst_asynctask.cpp index 37e33d5dcff..c438d1749b1 100644 --- a/tests/auto/utils/asynctask/tst_asynctask.cpp +++ b/tests/auto/utils/asynctask/tst_asynctask.cpp @@ -123,9 +123,9 @@ struct ConcurrentResultType template ::Type> -std::shared_ptr> createAsyncTask(Function &&function, Args &&...args) +std::shared_ptr> createAsyncTask(Function &&function, Args &&...args) { - auto asyncTask = std::make_shared>(); + auto asyncTask = std::make_shared>(); asyncTask->setConcurrentCallData(std::forward(function), std::forward(args)...); asyncTask->start(); return asyncTask; @@ -402,7 +402,7 @@ void tst_AsyncTask::futureSynchonizer() FutureSynchronizer synchronizer; synchronizer.setCancelOnWait(false); { - AsyncTask task; + Async task; task.setConcurrentCallData(lambda); task.setFutureSynchronizer(&synchronizer); task.start(); @@ -424,18 +424,18 @@ void tst_AsyncTask::taskTree() int value = 1; - const auto setupIntAsync = [&](AsyncTask &task) { + const auto setupIntAsync = [&](Async &task) { task.setConcurrentCallData(multiplyBy2, value); }; - const auto handleIntAsync = [&](const AsyncTask &task) { + const auto handleIntAsync = [&](const Async &task) { value = task.result(); }; const Group root { - Async(setupIntAsync, handleIntAsync), - Async(setupIntAsync, handleIntAsync), - Async(setupIntAsync, handleIntAsync), - Async(setupIntAsync, handleIntAsync), + AsyncTask(setupIntAsync, handleIntAsync), + AsyncTask(setupIntAsync, handleIntAsync), + AsyncTask(setupIntAsync, handleIntAsync), + AsyncTask(setupIntAsync, handleIntAsync), }; TaskTree tree(root); @@ -473,17 +473,17 @@ void tst_AsyncTask::mapReduce_data() s_sum = 0; s_results.append(s_sum); }; - const auto setupAsync = [](AsyncTask &task, int input) { + const auto setupAsync = [](Async &task, int input) { task.setConcurrentCallData(returnxx, input); }; - const auto setupAsyncWithFI = [](AsyncTask &task, int input) { + const auto setupAsyncWithFI = [](Async &task, int input) { task.setConcurrentCallData(returnxxWithPromise, input); }; - const auto setupAsyncWithTP = [this](AsyncTask &task, int input) { + const auto setupAsyncWithTP = [this](Async &task, int input) { task.setConcurrentCallData(returnxx, input); task.setThreadPool(&m_threadPool); }; - const auto handleAsync = [](const AsyncTask &task) { + const auto handleAsync = [](const Async &task) { s_sum += task.result(); s_results.append(task.result()); }; @@ -500,7 +500,7 @@ void tst_AsyncTask::mapReduce_data() using namespace Tasking; using namespace std::placeholders; - using SetupHandler = std::function &task, int input)>; + using SetupHandler = std::function &task, int input)>; using DoneHandler = std::function; const auto createTask = [=](const TaskItem &executeMode, @@ -509,11 +509,11 @@ void tst_AsyncTask::mapReduce_data() return Group { executeMode, OnGroupSetup(initTree), - Async(std::bind(setupHandler, _1, 1), handleAsync), - Async(std::bind(setupHandler, _1, 2), handleAsync), - Async(std::bind(setupHandler, _1, 3), handleAsync), - Async(std::bind(setupHandler, _1, 4), handleAsync), - Async(std::bind(setupHandler, _1, 5), handleAsync), + AsyncTask(std::bind(setupHandler, _1, 1), handleAsync), + AsyncTask(std::bind(setupHandler, _1, 2), handleAsync), + AsyncTask(std::bind(setupHandler, _1, 3), handleAsync), + AsyncTask(std::bind(setupHandler, _1, 4), handleAsync), + AsyncTask(std::bind(setupHandler, _1, 5), handleAsync), OnGroupDone(doneHandler) }; }; @@ -535,34 +535,34 @@ void tst_AsyncTask::mapReduce_data() QTest::newRow("SequentialWithFutureInterface") << sequentialRootWithFI << defaultSum << defaultResult; QTest::newRow("SequentialWithThreadPool") << sequentialRootWithTP << defaultSum << defaultResult; - const auto setupSimpleAsync = [](AsyncTask &task, int input) { + const auto setupSimpleAsync = [](Async &task, int input) { task.setConcurrentCallData([](int input) { return input * 2; }, input); }; - const auto handleSimpleAsync = [](const AsyncTask &task) { + const auto handleSimpleAsync = [](const Async &task) { s_sum += task.result() / 4.; s_results.append(s_sum); }; const Group simpleRoot = { sequential, OnGroupSetup([] { s_sum = 0; }), - Async(std::bind(setupSimpleAsync, _1, 1), handleSimpleAsync), - Async(std::bind(setupSimpleAsync, _1, 2), handleSimpleAsync), - Async(std::bind(setupSimpleAsync, _1, 3), handleSimpleAsync) + AsyncTask(std::bind(setupSimpleAsync, _1, 1), handleSimpleAsync), + AsyncTask(std::bind(setupSimpleAsync, _1, 2), handleSimpleAsync), + AsyncTask(std::bind(setupSimpleAsync, _1, 3), handleSimpleAsync) }; QTest::newRow("Simple") << simpleRoot << 3.0 << QList({.5, 1.5, 3.}); - const auto setupStringAsync = [](AsyncTask &task, const QString &input) { + const auto setupStringAsync = [](Async &task, const QString &input) { task.setConcurrentCallData([](const QString &input) -> int { return input.size(); }, input); }; - const auto handleStringAsync = [](const AsyncTask &task) { + const auto handleStringAsync = [](const Async &task) { s_sum /= task.result(); }; const Group stringRoot = { parallel, OnGroupSetup([] { s_sum = 90.0; }), - Async(std::bind(setupStringAsync, _1, "blubb"), handleStringAsync), - Async(std::bind(setupStringAsync, _1, "foo"), handleStringAsync), - Async(std::bind(setupStringAsync, _1, "blah"), handleStringAsync) + AsyncTask(std::bind(setupStringAsync, _1, "blubb"), handleStringAsync), + AsyncTask(std::bind(setupStringAsync, _1, "foo"), handleStringAsync), + AsyncTask(std::bind(setupStringAsync, _1, "blah"), handleStringAsync) }; QTest::newRow("String") << stringRoot << 1.5 << QList({}); } diff --git a/tests/auto/utils/tasktree/tst_tasktree.cpp b/tests/auto/utils/tasktree/tst_tasktree.cpp index 5bf8dcc006e..465c7f6bbb0 100644 --- a/tests/auto/utils/tasktree/tst_tasktree.cpp +++ b/tests/auto/utils/tasktree/tst_tasktree.cpp @@ -13,8 +13,8 @@ using namespace std::literals::chrono_literals; using namespace Utils; using namespace Utils::Tasking; -using TestTask = AsyncTask; -using Test = Async; +using TestTask = Async; +using Test = AsyncTask; enum class Handler { Setup, @@ -198,7 +198,7 @@ template auto setupBarrierAdvance(const TreeStorage &storage, const SharedBarrierType &barrier, int taskId) { - return [storage, barrier, taskId](AsyncTask &async) { + return [storage, barrier, taskId](Async &async) { async.setFutureSynchronizer(s_futureSynchronizer); async.setConcurrentCallData(reportAndSleep); async.setProperty(s_taskIdProperty, taskId); @@ -1213,7 +1213,7 @@ void tst_TaskTree::testTree_data() Storage(storage), Storage(barrier), sequential, - Async(setupBarrierAdvance(storage, barrier, 1)), + AsyncTask(setupBarrierAdvance(storage, barrier, 1)), Group { OnGroupSetup(groupSetup(2)), WaitForBarrier(barrier), @@ -1236,7 +1236,7 @@ void tst_TaskTree::testTree_data() Storage(storage), Storage(barrier), parallel, - Async(setupBarrierAdvance(storage, barrier, 1)), + AsyncTask(setupBarrierAdvance(storage, barrier, 1)), Group { OnGroupSetup(groupSetup(2)), WaitForBarrier(barrier), @@ -1272,7 +1272,7 @@ void tst_TaskTree::testTree_data() Test(setupTask(2)), Test(setupTask(3)) }, - Async(setupBarrierAdvance(storage, barrier, 1)) + AsyncTask(setupBarrierAdvance(storage, barrier, 1)) }; const Log log3 { {2, Handler::GroupSetup}, @@ -1289,7 +1289,7 @@ void tst_TaskTree::testTree_data() Storage(storage), Storage(barrier), parallel, - Async(setupBarrierAdvance(storage, barrier, 1)), + AsyncTask(setupBarrierAdvance(storage, barrier, 1)), Group { OnGroupSetup(groupSetup(2)), WaitForBarrier(barrier), @@ -1319,8 +1319,8 @@ void tst_TaskTree::testTree_data() Storage(barrier), Storage(barrier2), parallel, - Async(setupBarrierAdvance(storage, barrier, 0)), - Async(setupBarrierAdvance(storage, barrier2, 0)), + AsyncTask(setupBarrierAdvance(storage, barrier, 0)), + AsyncTask(setupBarrierAdvance(storage, barrier2, 0)), Group { Group { parallel, @@ -1363,8 +1363,8 @@ void tst_TaskTree::testTree_data() Storage(storage), Storage(barrier), sequential, - Async(setupBarrierAdvance(storage, barrier, 1)), - Async(setupBarrierAdvance(storage, barrier, 2)), + AsyncTask(setupBarrierAdvance(storage, barrier, 1)), + AsyncTask(setupBarrierAdvance(storage, barrier, 2)), Group { OnGroupSetup(groupSetup(2)), WaitForBarrier(barrier), @@ -1389,8 +1389,8 @@ void tst_TaskTree::testTree_data() Storage(storage), Storage(barrier), parallel, - Async(setupBarrierAdvance(storage, barrier, 0)), - Async(setupBarrierAdvance(storage, barrier, 0)), + AsyncTask(setupBarrierAdvance(storage, barrier, 0)), + AsyncTask(setupBarrierAdvance(storage, barrier, 0)), Group { OnGroupSetup(groupSetup(2)), WaitForBarrier(barrier), @@ -1428,8 +1428,8 @@ void tst_TaskTree::testTree_data() Test(setupTask(2)), Test(setupTask(3)) }, - Async(setupBarrierAdvance(storage, barrier, 0)), - Async(setupBarrierAdvance(storage, barrier, 0)) + AsyncTask(setupBarrierAdvance(storage, barrier, 0)), + AsyncTask(setupBarrierAdvance(storage, barrier, 0)) }; const Log log3 { {2, Handler::GroupSetup}, @@ -1448,8 +1448,8 @@ void tst_TaskTree::testTree_data() Storage(storage), Storage(barrier), parallel, - Async(setupBarrierAdvance(storage, barrier, 0)), - Async(setupBarrierAdvance(storage, barrier, 0)), + AsyncTask(setupBarrierAdvance(storage, barrier, 0)), + AsyncTask(setupBarrierAdvance(storage, barrier, 0)), Group { OnGroupSetup(groupSetup(2)), WaitForBarrier(barrier), diff --git a/tests/manual/tasktree/main.cpp b/tests/manual/tasktree/main.cpp index 22514300592..33087fa18dd 100644 --- a/tests/manual/tasktree/main.cpp +++ b/tests/manual/tasktree/main.cpp @@ -153,19 +153,19 @@ int main(int argc, char *argv[]) using namespace Tasking; auto taskItem = [sync = &synchronizer, synchronizerCheckBox](TaskWidget *widget) { - const auto setupHandler = [=](AsyncTask &task) { + const auto setupHandler = [=](Async &task) { task.setConcurrentCallData(sleepInThread, widget->busyTime(), widget->isSuccess()); if (synchronizerCheckBox->isChecked()) task.setFutureSynchronizer(sync); widget->setState(State::Running); }; - const auto doneHandler = [widget](const AsyncTask &) { + const auto doneHandler = [widget](const Async &) { widget->setState(State::Done); }; - const auto errorHandler = [widget](const AsyncTask &) { + const auto errorHandler = [widget](const Async &) { widget->setState(State::Error); }; - return Async(setupHandler, doneHandler, errorHandler); + return AsyncTask(setupHandler, doneHandler, errorHandler); }; const Group root {