TaskTree: Introduce CallDoneIf enum

Get rid of CustomTask c'tor taking 3 handlers.
If the done handler needs to be called only on
success or an error, add explicit 3rd arg of CallDoneIf type.

Task-number: QTCREATORBUG-29834
Change-Id: I10e55415587e6cac46620dd5177ad8269584583c
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2023-11-02 18:47:38 +01:00
parent 63bfeba87f
commit 6e6aa7102c
29 changed files with 148 additions and 127 deletions

View File

@@ -964,7 +964,7 @@ GroupItem GroupItem::withTimeout(const GroupItem &item, milliseconds timeout,
Group { Group {
finishAllAndError, finishAllAndError,
TimeoutTask([timeout](milliseconds &timeoutData) { timeoutData = timeout; }, TimeoutTask([timeout](milliseconds &timeoutData) { timeoutData = timeout; },
taskHandler) taskHandler, CallDoneIf::Success)
}, },
item item
}; };
@@ -1483,9 +1483,16 @@ void TaskNode::stop()
m_task.reset(); m_task.reset();
} }
static bool shouldCall(CallDoneIf callDoneIf, bool success)
{
if (success)
return callDoneIf != CallDoneIf::Error;
return callDoneIf != CallDoneIf::Success;
}
void TaskNode::invokeDoneHandler(bool success) void TaskNode::invokeDoneHandler(bool success)
{ {
if (m_taskHandler.m_doneHandler) if (m_taskHandler.m_doneHandler && shouldCall(m_taskHandler.m_callDoneIf, success))
invokeHandler(parentContainer(), m_taskHandler.m_doneHandler, *m_task.get(), success); invokeHandler(parentContainer(), m_taskHandler.m_doneHandler, *m_task.get(), success);
m_container.m_constData.m_taskTreePrivate->advanceProgress(1); m_container.m_constData.m_taskTreePrivate->advanceProgress(1);
} }

View File

@@ -112,7 +112,8 @@ private:
// 4. Always run all children, let them finish, ignore their results and report done afterwards. // 4. Always run all children, let them finish, ignore their results and report done afterwards.
// 5. Always run all children, let them finish, ignore their results and report error afterwards. // 5. Always run all children, let them finish, ignore their results and report error afterwards.
enum class WorkflowPolicy { enum class WorkflowPolicy
{
StopOnError, // 1a - Reports error on first child error, otherwise done (if all children were done). StopOnError, // 1a - Reports error on first child error, otherwise done (if all children were done).
ContinueOnError, // 1b - The same, but children execution continues. Reports done when no children. ContinueOnError, // 1b - The same, but children execution continues. Reports done when no children.
StopOnDone, // 2a - Reports done on first child done, otherwise error (if all children were error). StopOnDone, // 2a - Reports done on first child done, otherwise error (if all children were error).
@@ -131,6 +132,14 @@ enum class SetupResult
}; };
Q_ENUM_NS(SetupResult); Q_ENUM_NS(SetupResult);
enum class CallDoneIf
{
SuccessOrError,
Success,
Error
};
Q_ENUM_NS(CallDoneIf);
class TASKING_EXPORT GroupItem class TASKING_EXPORT GroupItem
{ {
public: public:
@@ -149,6 +158,7 @@ public:
TaskCreateHandler m_createHandler; TaskCreateHandler m_createHandler;
TaskSetupHandler m_setupHandler = {}; TaskSetupHandler m_setupHandler = {};
TaskDoneHandler m_doneHandler = {}; TaskDoneHandler m_doneHandler = {};
CallDoneIf m_callDoneIf = CallDoneIf::SuccessOrError;
}; };
struct GroupHandler { struct GroupHandler {
@@ -330,13 +340,15 @@ public:
static Adapter *createAdapter() { return new Adapter; } static Adapter *createAdapter() { return new Adapter; }
CustomTask() : GroupItem({&createAdapter}) {} CustomTask() : GroupItem({&createAdapter}) {}
template <typename SetupHandler = SetupFunction> template <typename SetupHandler = SetupFunction>
CustomTask(SetupHandler &&setup, const EndFunction &done = {}, const EndFunction &error = {}) CustomTask(SetupHandler &&setup, const EndFunction &done, CallDoneIf callDoneIf)
: GroupItem({&createAdapter, wrapSetup(std::forward<SetupHandler>(setup)), : GroupItem({&createAdapter, wrapSetup(std::forward<SetupHandler>(setup)), wrapEnd(done),
wrapEnds(done, error)}) {} callDoneIf}) {}
template <typename SetupHandler> template <typename SetupHandler>
CustomTask(SetupHandler &&setup, const DoneFunction &done) CustomTask(SetupHandler &&setup, const DoneFunction &done = {},
: GroupItem({&createAdapter, wrapSetup(std::forward<SetupHandler>(setup)), wrapDone(done)}) CallDoneIf callDoneIf = CallDoneIf::SuccessOrError)
: GroupItem({&createAdapter, wrapSetup(std::forward<SetupHandler>(setup)), wrapDone(done),
callDoneIf})
{} {}
GroupItem withTimeout(std::chrono::milliseconds timeout, GroupItem withTimeout(std::chrono::milliseconds timeout,
@@ -365,13 +377,11 @@ private:
}; };
}; };
static TaskDoneHandler wrapEnds(const EndFunction &doneHandler, const EndFunction &errorHandler) { static TaskDoneHandler wrapEnd(const EndFunction &handler) {
if (!doneHandler && !errorHandler) if (!handler)
return {}; return {};
return [doneHandler, errorHandler](const TaskInterface &taskInterface, bool success) { return [handler](const TaskInterface &taskInterface, bool) {
const Adapter &adapter = static_cast<const Adapter &>(taskInterface); const Adapter &adapter = static_cast<const Adapter &>(taskInterface);
const auto handler = success ? doneHandler : errorHandler;
if (handler)
handler(*adapter.task()); handler(*adapter.task());
}; };
}; };

View File

@@ -377,7 +377,7 @@ void TestCodeParser::scanForTests(const QSet<FilePath> &filePaths,
qCDebug(LOG) << "Using" << limit << "threads for scan."; qCDebug(LOG) << "Using" << limit << "threads for scan.";
QList<GroupItem> tasks{parallelLimit(limit)}; QList<GroupItem> tasks{parallelLimit(limit)};
for (const FilePath &file : filteredFiles) { for (const FilePath &file : filteredFiles) {
const auto setup = [this, codeParsers, file](Async<TestParseResultPtr> &async) { const auto onSetup = [this, codeParsers, file](Async<TestParseResultPtr> &async) {
async.setConcurrentCallData(parseFileForTests, codeParsers, file); async.setConcurrentCallData(parseFileForTests, codeParsers, file);
async.setPriority(QThread::LowestPriority); async.setPriority(QThread::LowestPriority);
async.setFutureSynchronizer(&m_futureSynchronizer); async.setFutureSynchronizer(&m_futureSynchronizer);
@@ -387,7 +387,7 @@ void TestCodeParser::scanForTests(const QSet<FilePath> &filePaths,
for (const TestParseResultPtr &result : results) for (const TestParseResultPtr &result : results)
emit testParseResultReady(result); emit testParseResultReady(result);
}; };
tasks.append(AsyncTask<TestParseResultPtr>(setup, onDone)); tasks.append(AsyncTask<TestParseResultPtr>(onSetup, onDone, CallDoneIf::Success));
} }
m_taskTree.reset(new TaskTree{tasks}); m_taskTree.reset(new TaskTree{tasks});
const auto onDone = [this] { m_taskTree.release()->deleteLater(); onFinished(true); }; const auto onDone = [this] { m_taskTree.release()->deleteLater(); onFinished(true); };

View File

@@ -171,7 +171,7 @@ static void filterCurrentResults(QPromise<void> &promise, const LocatorStorage &
[](const Entry &entry) { return entry.entry; })); [](const Entry &entry) { return entry.entry; }));
} }
LocatorMatcherTask currentDocumentMatcher() static LocatorMatcherTask currentDocumentMatcher()
{ {
using namespace Tasking; using namespace Tasking;
@@ -193,7 +193,7 @@ LocatorMatcherTask currentDocumentMatcher()
const Group root { const Group root {
Tasking::Storage(resultStorage), Tasking::Storage(resultStorage),
CurrentDocumentSymbolsRequestTask(onQuerySetup, onQueryDone), CurrentDocumentSymbolsRequestTask(onQuerySetup, onQueryDone, CallDoneIf::Success),
AsyncTask<void>(onFilterSetup) AsyncTask<void>(onFilterSetup)
}; };
return {root, storage}; return {root, storage};

View File

@@ -692,7 +692,7 @@ Group ClangTool::runRecipe(const RunSettings &runSettings,
m_runControl->postMessage(message, ErrorMessageFormat); m_runControl->postMessage(message, ErrorMessageFormat);
setState(State::PreparationFailed); setState(State::PreparationFailed);
}; };
topTasks.append(ProjectBuilderTask(onSetup, {}, onError)); topTasks.append(ProjectBuilderTask(onSetup, onError, CallDoneIf::Error));
} }
const ProjectInfo::ConstPtr projectInfoBeforeBuild const ProjectInfo::ConstPtr projectInfoBeforeBuild
@@ -821,7 +821,10 @@ Group ClangTool::runRecipe(const RunSettings &runSettings,
NormalMessageFormat); NormalMessageFormat);
}; };
topTasks.append(Group { Tasking::Storage(storage), TaskTreeTask(onTreeSetup, onTreeDone) }); topTasks.append(Group {
Tasking::Storage(storage),
TaskTreeTask(onTreeSetup, onTreeDone, CallDoneIf::Success)
});
return {topTasks}; return {topTasks};
} }

View File

@@ -374,7 +374,7 @@ GroupItem CMakeBuildStep::runRecipe()
}; };
Group root { Group root {
ignoreReturnValue() ? finishAllAndDone : stopOnError, ignoreReturnValue() ? finishAllAndDone : stopOnError,
ProjectParserTask(onParserSetup, {}, onParserError), ProjectParserTask(onParserSetup, onParserError, CallDoneIf::Error),
defaultProcessTask(), defaultProcessTask(),
onGroupDone(onEnd), onGroupDone(onEnd),
onGroupError(onEnd) onGroupError(onEnd)

View File

@@ -88,18 +88,18 @@ DirectoryFilter::DirectoryFilter(Id id)
m_cache.setFilePaths({}); m_cache.setFilePaths({});
return SetupResult::StopWithDone; // Group stops, skips async task return SetupResult::StopWithDone; // Group stops, skips async task
}; };
const auto asyncSetup = [this](Async<FilePaths> &async) { const auto onSetup = [this](Async<FilePaths> &async) {
async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer());
async.setConcurrentCallData(&refresh, m_directories, m_filters, m_exclusionFilters, async.setConcurrentCallData(&refresh, m_directories, m_filters, m_exclusionFilters,
displayName()); displayName());
}; };
const auto asyncDone = [this](const Async<FilePaths> &async) { const auto onDone = [this](const Async<FilePaths> &async) {
if (async.isResultAvailable()) if (async.isResultAvailable())
m_cache.setFilePaths(async.result()); m_cache.setFilePaths(async.result());
}; };
const Group root { const Group root {
onGroupSetup(groupSetup), onGroupSetup(groupSetup),
AsyncTask<FilePaths>(asyncSetup, asyncDone) AsyncTask<FilePaths>(onSetup, onDone, CallDoneIf::Success)
}; };
setRefreshRecipe(root); setRefreshRecipe(root);
} }

View File

@@ -1526,7 +1526,7 @@ LocatorMatcherTask LocatorFileCache::matcher() const
that->update(async.result()); that->update(async.result());
}; };
return {AsyncTask<LocatorFileCachePrivate>(onSetup, onDone), storage}; return {AsyncTask<LocatorFileCachePrivate>(onSetup, onDone, CallDoneIf::Success), storage};
} }
} // Core } // Core

View File

@@ -257,8 +257,8 @@ public:
}; };
const Group root { const Group root {
UnarchiverTask(onUnarchiverSetup, {}, onUnarchiverError), UnarchiverTask(onUnarchiverSetup, onUnarchiverError, CallDoneIf::Error),
AsyncTask<ArchiveIssue>(onCheckerSetup, onCheckerDone) AsyncTask<ArchiveIssue>(onCheckerSetup, onCheckerDone, CallDoneIf::Success)
}; };
m_taskTree.reset(new TaskTree(root)); m_taskTree.reset(new TaskTree(root));

View File

@@ -52,7 +52,7 @@ void CppProjectUpdater::update(const ProjectUpdateInfo &projectUpdateInfo,
ProjectInfo::ConstPtr projectInfo = nullptr; ProjectInfo::ConstPtr projectInfo = nullptr;
}; };
const TreeStorage<UpdateStorage> storage; const TreeStorage<UpdateStorage> storage;
const auto setupInfoGenerator = [=](Async<ProjectInfo::ConstPtr> &async) { const auto onInfoGeneratorSetup = [=](Async<ProjectInfo::ConstPtr> &async) {
async.setConcurrentCallData(infoGenerator); async.setConcurrentCallData(infoGenerator);
async.setFutureSynchronizer(&m_futureSynchronizer); async.setFutureSynchronizer(&m_futureSynchronizer);
}; };
@@ -61,7 +61,8 @@ void CppProjectUpdater::update(const ProjectUpdateInfo &projectUpdateInfo,
storage->projectInfo = async.result(); storage->projectInfo = async.result();
}; };
QList<GroupItem> tasks{parallel}; QList<GroupItem> tasks{parallel};
tasks.append(AsyncTask<ProjectInfo::ConstPtr>(setupInfoGenerator, onInfoGeneratorDone)); tasks.append(AsyncTask<ProjectInfo::ConstPtr>(onInfoGeneratorSetup, onInfoGeneratorDone,
CallDoneIf::Success));
for (QPointer<ExtraCompiler> compiler : compilers) { for (QPointer<ExtraCompiler> compiler : compilers) {
if (compiler && compiler->isDirty()) if (compiler && compiler->isDirty())
tasks.append(compiler->compileFileItem()); tasks.append(compiler->compileFileItem());

View File

@@ -253,11 +253,13 @@ void AttachCoreDialog::accepted()
AsyncTask<ResultType>{[=](auto &task) { AsyncTask<ResultType>{[=](auto &task) {
task.setConcurrentCallData(copyFileAsync, this->coreFile()); task.setConcurrentCallData(copyFileAsync, this->coreFile());
}, },
[=](const auto &task) { d->coreFileResult = task.result(); }}, [=](const auto &task) { d->coreFileResult = task.result(); },
CallDoneIf::Success},
AsyncTask<ResultType>{[=](auto &task) { AsyncTask<ResultType>{[=](auto &task) {
task.setConcurrentCallData(copyFileAsync, this->symbolFile()); task.setConcurrentCallData(copyFileAsync, this->symbolFile());
}, },
[=](const auto &task) { d->symbolFileResult = task.result(); }}, [=](const auto &task) { d->symbolFileResult = task.result(); },
CallDoneIf::Success}
}; };
d->taskTree.setRecipe(root); d->taskTree.setRecipe(root);

View File

@@ -118,7 +118,7 @@ DiffFilesController::DiffFilesController(IDocument *document)
QList<GroupItem> tasks { parallel, finishAllAndDone }; QList<GroupItem> tasks { parallel, finishAllAndDone };
for (int i = 0; i < inputList.size(); ++i) { for (int i = 0; i < inputList.size(); ++i) {
const auto setupDiff = [this, reloadInput = inputList.at(i)](Async<FileData> &async) { const auto onDiffSetup = [this, reloadInput = inputList.at(i)](Async<FileData> &async) {
async.setConcurrentCallData( async.setConcurrentCallData(
DiffFile(ignoreWhitespace(), contextLineCount()), reloadInput); DiffFile(ignoreWhitespace(), contextLineCount()), reloadInput);
async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer());
@@ -128,7 +128,7 @@ DiffFilesController::DiffFilesController(IDocument *document)
if (async.isResultAvailable()) if (async.isResultAvailable())
(*outputList)[i] = async.result(); (*outputList)[i] = async.result();
}; };
tasks.append(AsyncTask<FileData>(setupDiff, onDiffDone)); tasks.append(AsyncTask<FileData>(onDiffSetup, onDiffDone, CallDoneIf::Success));
} }
taskTree.setRecipe(tasks); taskTree.setRecipe(tasks);
}; };

View File

@@ -547,7 +547,7 @@ TaskTree *BranchView::onFastForwardMerge(const std::function<void()> &callback)
const TreeStorage<FastForwardStorage> storage; const TreeStorage<FastForwardStorage> storage;
const auto setupMergeBase = [repository = m_repository, branch](Process &process) { const auto onMergeBaseSetup = [repository = m_repository, branch](Process &process) {
gitClient().setupCommand(process, repository, {"merge-base", "HEAD", branch}); gitClient().setupCommand(process, repository, {"merge-base", "HEAD", branch});
}; };
const auto onMergeBaseDone = [storage](const Process &process) { const auto onMergeBaseDone = [storage](const Process &process) {
@@ -563,7 +563,7 @@ TaskTree *BranchView::onFastForwardMerge(const std::function<void()> &callback)
const Group root { const Group root {
Tasking::Storage(storage), Tasking::Storage(storage),
parallel, parallel,
ProcessTask(setupMergeBase, onMergeBaseDone), ProcessTask(onMergeBaseSetup, onMergeBaseDone, CallDoneIf::Success),
topRevisionProc, topRevisionProc,
onGroupDone([storage, callback] { onGroupDone([storage, callback] {
if (storage->mergeBase == storage->topRevision) if (storage->mergeBase == storage->topRevision)

View File

@@ -238,7 +238,7 @@ GitDiffEditorController::GitDiffEditorController(IDocument *document,
{ {
const TreeStorage<QString> diffInputStorage; const TreeStorage<QString> diffInputStorage;
const auto setupDiff = [=](Process &process) { const auto onDiffSetup = [=](Process &process) {
process.setCodec(VcsBaseEditor::getCodec(workingDirectory(), {})); process.setCodec(VcsBaseEditor::getCodec(workingDirectory(), {}));
setupCommand(process, {addConfigurationArguments(diffArgs(leftCommit, rightCommit, extraArgs))}); setupCommand(process, {addConfigurationArguments(diffArgs(leftCommit, rightCommit, extraArgs))});
VcsOutputWindow::appendCommand(process.workingDirectory(), process.commandLine()); VcsOutputWindow::appendCommand(process.workingDirectory(), process.commandLine());
@@ -249,7 +249,7 @@ GitDiffEditorController::GitDiffEditorController(IDocument *document,
const Group root { const Group root {
Tasking::Storage(diffInputStorage), Tasking::Storage(diffInputStorage),
ProcessTask(setupDiff, onDiffDone), ProcessTask(onDiffSetup, onDiffDone, CallDoneIf::Success),
postProcessTask(diffInputStorage) postProcessTask(diffInputStorage)
}; };
setReloadRecipe(root); setReloadRecipe(root);
@@ -302,7 +302,7 @@ FileListDiffController::FileListDiffController(IDocument *document, const QStrin
const TreeStorage<DiffStorage> storage; const TreeStorage<DiffStorage> storage;
const TreeStorage<QString> diffInputStorage; const TreeStorage<QString> diffInputStorage;
const auto setupStaged = [this, stagedFiles](Process &process) { const auto onStagedSetup = [this, stagedFiles](Process &process) {
if (stagedFiles.isEmpty()) if (stagedFiles.isEmpty())
return SetupResult::StopWithError; return SetupResult::StopWithError;
process.setCodec(VcsBaseEditor::getCodec(workingDirectory(), stagedFiles)); process.setCodec(VcsBaseEditor::getCodec(workingDirectory(), stagedFiles));
@@ -315,7 +315,7 @@ FileListDiffController::FileListDiffController(IDocument *document, const QStrin
storage->m_stagedOutput = process.cleanedStdOut(); storage->m_stagedOutput = process.cleanedStdOut();
}; };
const auto setupUnstaged = [this, unstagedFiles](Process &process) { const auto onUnstagedSetup = [this, unstagedFiles](Process &process) {
if (unstagedFiles.isEmpty()) if (unstagedFiles.isEmpty())
return SetupResult::StopWithError; return SetupResult::StopWithError;
process.setCodec(VcsBaseEditor::getCodec(workingDirectory(), unstagedFiles)); process.setCodec(VcsBaseEditor::getCodec(workingDirectory(), unstagedFiles));
@@ -328,7 +328,7 @@ FileListDiffController::FileListDiffController(IDocument *document, const QStrin
storage->m_unstagedOutput = process.cleanedStdOut(); storage->m_unstagedOutput = process.cleanedStdOut();
}; };
const auto onStagingDone = [storage, diffInputStorage] { const auto onDone = [storage, diffInputStorage] {
*diffInputStorage = storage->m_stagedOutput + storage->m_unstagedOutput; *diffInputStorage = storage->m_stagedOutput + storage->m_unstagedOutput;
}; };
@@ -338,9 +338,9 @@ FileListDiffController::FileListDiffController(IDocument *document, const QStrin
Group { Group {
parallel, parallel,
continueOnDone, continueOnDone,
ProcessTask(setupStaged, onStagedDone), ProcessTask(onStagedSetup, onStagedDone, CallDoneIf::Success),
ProcessTask(setupUnstaged, onUnstagedDone), ProcessTask(onUnstagedSetup, onUnstagedDone, CallDoneIf::Success),
onGroupDone(onStagingDone) onGroupDone(onDone)
}, },
postProcessTask(diffInputStorage) postProcessTask(diffInputStorage)
}; };
@@ -500,14 +500,14 @@ ShowController::ShowController(IDocument *document, const QString &id)
QList<GroupItem> tasks { parallel, continueOnDone, onGroupError(onFollowsError) }; QList<GroupItem> tasks { parallel, continueOnDone, onGroupError(onFollowsError) };
for (int i = 0, total = parents.size(); i < total; ++i) { for (int i = 0, total = parents.size(); i < total; ++i) {
const auto setupFollow = [this, parent = parents.at(i)](Process &process) { const auto onFollowSetup = [this, parent = parents.at(i)](Process &process) {
setupCommand(process, {"describe", "--tags", "--abbrev=0", parent}); setupCommand(process, {"describe", "--tags", "--abbrev=0", parent});
}; };
const auto onFollowDone = [data, updateDescription, i](const Process &process) { const auto onFollowDone = [data, updateDescription, i](const Process &process) {
data->m_follows[i] = process.cleanedStdOut().trimmed(); data->m_follows[i] = process.cleanedStdOut().trimmed();
updateDescription(*data); updateDescription(*data);
}; };
tasks.append(ProcessTask(setupFollow, onFollowDone)); tasks.append(ProcessTask(onFollowSetup, onFollowDone, CallDoneIf::Success));
} }
taskTree.setRecipe(tasks); taskTree.setRecipe(tasks);
}; };
@@ -529,18 +529,18 @@ ShowController::ShowController(IDocument *document, const QString &id)
onGroupSetup([this] { setStartupFile(VcsBase::source(this->document()).toString()); }), onGroupSetup([this] { setStartupFile(VcsBase::source(this->document()).toString()); }),
Group { Group {
finishAllAndDone, finishAllAndDone,
ProcessTask(onDescriptionSetup, onDescriptionDone), ProcessTask(onDescriptionSetup, onDescriptionDone, CallDoneIf::Success),
Group { Group {
parallel, parallel,
finishAllAndDone, finishAllAndDone,
onGroupSetup(desciptionDetailsSetup), onGroupSetup(desciptionDetailsSetup),
ProcessTask(onBranchesSetup, onBranchesDone), ProcessTask(onBranchesSetup, onBranchesDone, CallDoneIf::Success),
ProcessTask(onPrecedesSetup, onPrecedesDone), ProcessTask(onPrecedesSetup, onPrecedesDone, CallDoneIf::Success),
TaskTreeTask(setupFollows) TaskTreeTask(setupFollows)
} }
}, },
Group { Group {
ProcessTask(onDiffSetup, onDiffDone), ProcessTask(onDiffSetup, onDiffDone, CallDoneIf::Success),
postProcessTask(diffInputStorage) postProcessTask(diffInputStorage)
} }
}; };
@@ -1712,7 +1712,7 @@ bool GitClient::synchronousRevParseCmd(const FilePath &workingDirectory, const Q
GroupItem GitClient::topRevision(const FilePath &workingDirectory, GroupItem GitClient::topRevision(const FilePath &workingDirectory,
const std::function<void(const QString &, const QDateTime &)> &callback) const std::function<void(const QString &, const QDateTime &)> &callback)
{ {
const auto setupProcess = [this, workingDirectory](Process &process) { const auto onProcessSetup = [this, workingDirectory](Process &process) {
setupCommand(process, workingDirectory, {"show", "-s", "--pretty=format:%H:%ct", HEAD}); setupCommand(process, workingDirectory, {"show", "-s", "--pretty=format:%H:%ct", HEAD});
}; };
const auto onProcessDone = [callback](const Process &process) { const auto onProcessDone = [callback](const Process &process) {
@@ -1727,7 +1727,7 @@ GroupItem GitClient::topRevision(const FilePath &workingDirectory,
callback(output.first(), dateTime); callback(output.first(), dateTime);
}; };
return ProcessTask(setupProcess, onProcessDone); return ProcessTask(onProcessSetup, onProcessDone, CallDoneIf::Success);
} }
bool GitClient::isRemoteCommit(const FilePath &workingDirectory, const QString &commit) bool GitClient::isRemoteCommit(const FilePath &workingDirectory, const QString &commit)

View File

@@ -105,7 +105,7 @@ LocatorMatcherTasks HelpIndexFilter::matchers()
} }
}; };
return {{AsyncTask<QStringList>(onSetup, onDone), storage}}; return {{AsyncTask<QStringList>(onSetup, onDone, CallDoneIf::Success), storage}};
} }
void HelpIndexFilter::invalidateCache() void HelpIndexFilter::invalidateCache()

View File

@@ -77,7 +77,7 @@ LocatorMatcherTask locatorMatcher(Client *client, int maxResultCount,
const Group root { const Group root {
Tasking::Storage(resultStorage), Tasking::Storage(resultStorage),
ClientWorkspaceSymbolRequestTask(onQuerySetup, onQueryDone), ClientWorkspaceSymbolRequestTask(onQuerySetup, onQueryDone, CallDoneIf::Success),
AsyncTask<void>(onFilterSetup) AsyncTask<void>(onFilterSetup)
}; };
return {root, storage}; return {root, storage};
@@ -136,7 +136,7 @@ LocatorMatcherTask currentDocumentMatcher()
const Group root { const Group root {
Tasking::Storage(resultStorage), Tasking::Storage(resultStorage),
CurrentDocumentSymbolsRequestTask(onQuerySetup, onQueryDone), CurrentDocumentSymbolsRequestTask(onQuerySetup, onQueryDone, CallDoneIf::Success),
AsyncTask<void>(onFilterSetup) AsyncTask<void>(onFilterSetup)
}; };
return {root, storage}; return {root, storage};

View File

@@ -55,7 +55,7 @@ MercurialDiffEditorController::MercurialDiffEditorController(IDocument *document
const TreeStorage<QString> diffInputStorage; const TreeStorage<QString> diffInputStorage;
const auto setupDiff = [=](Process &process) { const auto onDiffSetup = [=](Process &process) {
setupCommand(process, {addConfigurationArguments(args)}); setupCommand(process, {addConfigurationArguments(args)});
VcsOutputWindow::appendCommand(process.workingDirectory(), process.commandLine()); VcsOutputWindow::appendCommand(process.workingDirectory(), process.commandLine());
}; };
@@ -65,7 +65,7 @@ MercurialDiffEditorController::MercurialDiffEditorController(IDocument *document
const Group root { const Group root {
Tasking::Storage(diffInputStorage), Tasking::Storage(diffInputStorage),
ProcessTask(setupDiff, onDiffDone), ProcessTask(onDiffSetup, onDiffDone, CallDoneIf::Success),
postProcessTask(diffInputStorage) postProcessTask(diffInputStorage)
}; };
setReloadRecipe(root); setReloadRecipe(root);

View File

@@ -328,14 +328,14 @@ ProcessExtraCompiler::ProcessExtraCompiler(const Project *project, const FilePat
GroupItem ProcessExtraCompiler::taskItemImpl(const ContentProvider &provider) GroupItem ProcessExtraCompiler::taskItemImpl(const ContentProvider &provider)
{ {
const auto setupTask = [=](Async<FileNameToContentsHash> &async) { const auto onSetup = [=](Async<FileNameToContentsHash> &async) {
async.setThreadPool(extraCompilerThreadPool()); async.setThreadPool(extraCompilerThreadPool());
// The passed synchronizer has cancelOnWait set to true by default. // The passed synchronizer has cancelOnWait set to true by default.
async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer());
async.setConcurrentCallData(&ProcessExtraCompiler::runInThread, this, command(), async.setConcurrentCallData(&ProcessExtraCompiler::runInThread, this, command(),
workingDirectory(), arguments(), provider, buildEnvironment()); workingDirectory(), arguments(), provider, buildEnvironment());
}; };
const auto taskDone = [=](const Async<FileNameToContentsHash> &async) { const auto onDone = [=](const Async<FileNameToContentsHash> &async) {
if (!async.isResultAvailable()) if (!async.isResultAvailable())
return; return;
const FileNameToContentsHash data = async.result(); const FileNameToContentsHash data = async.result();
@@ -345,7 +345,7 @@ GroupItem ProcessExtraCompiler::taskItemImpl(const ContentProvider &provider)
setContent(it.key(), it.value()); setContent(it.key(), it.value());
updateCompileTime(); updateCompileTime();
}; };
return AsyncTask<FileNameToContentsHash>(setupTask, taskDone); return AsyncTask<FileNameToContentsHash>(onSetup, onDone, CallDoneIf::Success);
} }
FilePath ProcessExtraCompiler::workingDirectory() const FilePath ProcessExtraCompiler::workingDirectory() const

View File

@@ -147,24 +147,24 @@ GroupItem QnxDeployQtLibrariesDialogPrivate::checkDirTask()
GroupItem QnxDeployQtLibrariesDialogPrivate::removeDirTask() GroupItem QnxDeployQtLibrariesDialogPrivate::removeDirTask()
{ {
const auto setupHandler = [this](Process &process) { const auto onSetup = [this](Process &process) {
if (m_checkResult != CheckResult::RemoveDir) if (m_checkResult != CheckResult::RemoveDir)
return SetupResult::StopWithDone; return SetupResult::StopWithDone;
m_deployLogWindow->appendPlainText(Tr::tr("Removing \"%1\"").arg(fullRemoteDirectory())); m_deployLogWindow->appendPlainText(Tr::tr("Removing \"%1\"").arg(fullRemoteDirectory()));
process.setCommand({m_device->filePath("rm"), {"-rf", fullRemoteDirectory()}}); process.setCommand({m_device->filePath("rm"), {"-rf", fullRemoteDirectory()}});
return SetupResult::Continue; return SetupResult::Continue;
}; };
const auto errorHandler = [this](const Process &process) { const auto onError = [this](const Process &process) {
QTC_ASSERT(process.exitCode() == 0, return); QTC_ASSERT(process.exitCode() == 0, return);
m_deployLogWindow->appendPlainText(Tr::tr("Connection failed: %1") m_deployLogWindow->appendPlainText(Tr::tr("Connection failed: %1")
.arg(process.errorString())); .arg(process.errorString()));
}; };
return ProcessTask(setupHandler, {}, errorHandler); return ProcessTask(onSetup, onError, CallDoneIf::Error);
} }
GroupItem QnxDeployQtLibrariesDialogPrivate::uploadTask() GroupItem QnxDeployQtLibrariesDialogPrivate::uploadTask()
{ {
const auto setupHandler = [this](FileTransfer &transfer) { const auto onSetup = [this](FileTransfer &transfer) {
if (m_deployableFiles.isEmpty()) { if (m_deployableFiles.isEmpty()) {
emitProgressMessage(Tr::tr("No files need to be uploaded.")); emitProgressMessage(Tr::tr("No files need to be uploaded."));
return SetupResult::StopWithDone; return SetupResult::StopWithDone;
@@ -190,19 +190,19 @@ GroupItem QnxDeployQtLibrariesDialogPrivate::uploadTask()
this, &QnxDeployQtLibrariesDialogPrivate::emitProgressMessage); this, &QnxDeployQtLibrariesDialogPrivate::emitProgressMessage);
return SetupResult::Continue; return SetupResult::Continue;
}; };
const auto errorHandler = [this](const FileTransfer &transfer) { const auto onError = [this](const FileTransfer &transfer) {
emitErrorMessage(transfer.resultData().m_errorString); emitErrorMessage(transfer.resultData().m_errorString);
}; };
return FileTransferTask(setupHandler, {}, errorHandler); return FileTransferTask(onSetup, onError, CallDoneIf::Error);
} }
GroupItem QnxDeployQtLibrariesDialogPrivate::chmodTask(const DeployableFile &file) GroupItem QnxDeployQtLibrariesDialogPrivate::chmodTask(const DeployableFile &file)
{ {
const auto setupHandler = [=](Process &process) { const auto onSetup = [=](Process &process) {
process.setCommand({m_device->filePath("chmod"), process.setCommand({m_device->filePath("chmod"),
{"a+x", Utils::ProcessArgs::quoteArgUnix(file.remoteFilePath())}}); {"a+x", Utils::ProcessArgs::quoteArgUnix(file.remoteFilePath())}});
}; };
const auto errorHandler = [=](const Process &process) { const auto onError = [=](const Process &process) {
const QString error = process.errorString(); const QString error = process.errorString();
if (!error.isEmpty()) { if (!error.isEmpty()) {
emitWarningMessage(Tr::tr("Remote chmod failed for file \"%1\": %2") emitWarningMessage(Tr::tr("Remote chmod failed for file \"%1\": %2")
@@ -212,7 +212,7 @@ GroupItem QnxDeployQtLibrariesDialogPrivate::chmodTask(const DeployableFile &fil
.arg(file.remoteFilePath(), process.cleanedStdErr())); .arg(file.remoteFilePath(), process.cleanedStdErr()));
} }
}; };
return ProcessTask(setupHandler, {}, errorHandler); return ProcessTask(onSetup, onError, CallDoneIf::Error);
} }
GroupItem QnxDeployQtLibrariesDialogPrivate::chmodTree() GroupItem QnxDeployQtLibrariesDialogPrivate::chmodTree()

View File

@@ -62,7 +62,7 @@ void QnxDeviceTester::testDevice(const ProjectExplorer::IDevice::Ptr &device)
: Tr::tr("Files cannot be created in %1.").arg(Constants::QNX_TMP_DIR); : Tr::tr("Files cannot be created in %1.").arg(Constants::QNX_TMP_DIR);
emit errorMessage(message + '\n'); emit errorMessage(message + '\n');
}; };
setExtraTests({ProcessTask(onSetup, onDone)}); setExtraTests({ProcessTask(onSetup, onDone, CallDoneIf::Success)});
RemoteLinux::GenericLinuxDeviceTester::testDevice(device); RemoteLinux::GenericLinuxDeviceTester::testDevice(device);
} }

View File

@@ -71,8 +71,8 @@ void Slog2InfoRunner::start()
const Group root { const Group root {
ProcessTask(onTestSetup, onTestDone), ProcessTask(onTestSetup, onTestDone),
ProcessTask(onLaunchTimeSetup, onLaunchTimeDone), ProcessTask(onLaunchTimeSetup, onLaunchTimeDone, CallDoneIf::Success),
ProcessTask(onLogSetup, {}, onLogError) ProcessTask(onLogSetup, onLogError, CallDoneIf::Error)
}; };
m_taskTree.reset(new TaskTree(root)); m_taskTree.reset(new TaskTree(root));

View File

@@ -443,32 +443,32 @@ void FileSystemAccessTest::testFileStreamer()
return FileStreamerTask(setup); return FileStreamerTask(setup);
}; };
const auto localReader = [&] { const auto localReader = [&] {
const auto setup = [&](FileStreamer &streamer) { const auto onSetup = [&](FileStreamer &streamer) {
streamer.setStreamMode(StreamMode::Reader); streamer.setStreamMode(StreamMode::Reader);
streamer.setSource(localSourcePath); streamer.setSource(localSourcePath);
}; };
const auto onDone = [&](const FileStreamer &streamer) { const auto onDone = [&](const FileStreamer &streamer) {
localData = streamer.readData(); localData = streamer.readData();
}; };
return FileStreamerTask(setup, onDone); return FileStreamerTask(onSetup, onDone, CallDoneIf::Success);
}; };
const auto remoteReader = [&] { const auto remoteReader = [&] {
const auto setup = [&](FileStreamer &streamer) { const auto onSetup = [&](FileStreamer &streamer) {
streamer.setStreamMode(StreamMode::Reader); streamer.setStreamMode(StreamMode::Reader);
streamer.setSource(remoteSourcePath); streamer.setSource(remoteSourcePath);
}; };
const auto onDone = [&](const FileStreamer &streamer) { const auto onDone = [&](const FileStreamer &streamer) {
remoteData = streamer.readData(); remoteData = streamer.readData();
}; };
return FileStreamerTask(setup, onDone); return FileStreamerTask(onSetup, onDone, CallDoneIf::Success);
}; };
const auto transfer = [](const FilePath &source, const FilePath &dest, const auto transfer = [](const FilePath &source, const FilePath &dest,
std::optional<QByteArray> *result) { std::optional<QByteArray> *result) {
const auto setupTransfer = [=](FileStreamer &streamer) { const auto onTransferSetup = [=](FileStreamer &streamer) {
streamer.setSource(source); streamer.setSource(source);
streamer.setDestination(dest); streamer.setDestination(dest);
}; };
const auto setupReader = [=](FileStreamer &streamer) { const auto onReaderSetup = [=](FileStreamer &streamer) {
streamer.setStreamMode(StreamMode::Reader); streamer.setStreamMode(StreamMode::Reader);
streamer.setSource(dest); streamer.setSource(dest);
}; };
@@ -476,8 +476,8 @@ void FileSystemAccessTest::testFileStreamer()
*result = streamer.readData(); *result = streamer.readData();
}; };
const Group root { const Group root {
FileStreamerTask(setupTransfer), FileStreamerTask(onTransferSetup),
FileStreamerTask(setupReader, onReaderDone) FileStreamerTask(onReaderSetup, onReaderDone, CallDoneIf::Success)
}; };
return root; return root;
}; };

View File

@@ -109,7 +109,7 @@ GroupItem GenericDeployStep::mkdirTask(const TreeStorage<FilesToTransfer> &stora
} }
}; };
return AsyncTask<ResultType>(onSetup, {}, onError); return AsyncTask<ResultType>(onSetup, onError, CallDoneIf::Error);
} }
static FileTransferMethod supportedTransferMethodFor(const FileToTransfer &fileToTransfer) static FileTransferMethod supportedTransferMethodFor(const FileToTransfer &fileToTransfer)
@@ -135,7 +135,7 @@ static FileTransferMethod supportedTransferMethodFor(const FileToTransfer &fileT
GroupItem GenericDeployStep::transferTask(const TreeStorage<FilesToTransfer> &storage) GroupItem GenericDeployStep::transferTask(const TreeStorage<FilesToTransfer> &storage)
{ {
const auto setupHandler = [this, storage](FileTransfer &transfer) { const auto onSetup = [this, storage](FileTransfer &transfer) {
FileTransferMethod preferredTransferMethod = FileTransferMethod::Rsync; FileTransferMethod preferredTransferMethod = FileTransferMethod::Rsync;
if (method() == 0) if (method() == 0)
preferredTransferMethod = FileTransferMethod::Rsync; preferredTransferMethod = FileTransferMethod::Rsync;
@@ -164,7 +164,7 @@ GroupItem GenericDeployStep::transferTask(const TreeStorage<FilesToTransfer> &st
transfer.setFilesToTransfer(*storage); transfer.setFilesToTransfer(*storage);
connect(&transfer, &FileTransfer::progress, this, &GenericDeployStep::handleStdOutData); connect(&transfer, &FileTransfer::progress, this, &GenericDeployStep::handleStdOutData);
}; };
const auto errorHandler = [this](const FileTransfer &transfer) { const auto onError = [this](const FileTransfer &transfer) {
const ProcessResultData result = transfer.resultData(); const ProcessResultData result = transfer.resultData();
if (result.m_error == QProcess::FailedToStart) { if (result.m_error == QProcess::FailedToStart) {
addErrorMessage(Tr::tr("rsync failed to start: %1").arg(result.m_errorString)); addErrorMessage(Tr::tr("rsync failed to start: %1").arg(result.m_errorString));
@@ -175,7 +175,7 @@ GroupItem GenericDeployStep::transferTask(const TreeStorage<FilesToTransfer> &st
+ "\n" + result.m_errorString); + "\n" + result.m_errorString);
} }
}; };
return FileTransferTask(setupHandler, {}, errorHandler); return FileTransferTask(onSetup, onError, CallDoneIf::Error);
} }
GroupItem GenericDeployStep::deployRecipe() GroupItem GenericDeployStep::deployRecipe()

View File

@@ -166,7 +166,7 @@ GroupItem GenericDirectUploadStep::statTree(const TreeStorage<UploadStorage> &st
GroupItem GenericDirectUploadStep::uploadTask(const TreeStorage<UploadStorage> &storage) GroupItem GenericDirectUploadStep::uploadTask(const TreeStorage<UploadStorage> &storage)
{ {
const auto setupHandler = [this, storage](FileTransfer &transfer) { const auto onSetup = [this, storage](FileTransfer &transfer) {
if (storage->filesToUpload.isEmpty()) { if (storage->filesToUpload.isEmpty()) {
addProgressMessage(Tr::tr("No files need to be uploaded.")); addProgressMessage(Tr::tr("No files need to be uploaded."));
return SetupResult::StopWithDone; return SetupResult::StopWithDone;
@@ -197,20 +197,20 @@ GroupItem GenericDirectUploadStep::uploadTask(const TreeStorage<UploadStorage> &
this, &GenericDirectUploadStep::addProgressMessage); this, &GenericDirectUploadStep::addProgressMessage);
return SetupResult::Continue; return SetupResult::Continue;
}; };
const auto errorHandler = [this](const FileTransfer &transfer) { const auto onError = [this](const FileTransfer &transfer) {
addErrorMessage(transfer.resultData().m_errorString); addErrorMessage(transfer.resultData().m_errorString);
}; };
return FileTransferTask(setupHandler, {}, errorHandler); return FileTransferTask(onSetup, onError, CallDoneIf::Error);
} }
GroupItem GenericDirectUploadStep::chmodTask(const DeployableFile &file) GroupItem GenericDirectUploadStep::chmodTask(const DeployableFile &file)
{ {
const auto setupHandler = [=](Process &process) { const auto onSetup = [=](Process &process) {
process.setCommand({deviceConfiguration()->filePath("chmod"), process.setCommand({deviceConfiguration()->filePath("chmod"),
{"a+x", Utils::ProcessArgs::quoteArgUnix(file.remoteFilePath())}}); {"a+x", Utils::ProcessArgs::quoteArgUnix(file.remoteFilePath())}});
}; };
const auto errorHandler = [=](const Process &process) { const auto onError = [=](const Process &process) {
const QString error = process.errorString(); const QString error = process.errorString();
if (!error.isEmpty()) { if (!error.isEmpty()) {
addWarningMessage(Tr::tr("Remote chmod failed for file \"%1\": %2") addWarningMessage(Tr::tr("Remote chmod failed for file \"%1\": %2")
@@ -220,7 +220,7 @@ GroupItem GenericDirectUploadStep::chmodTask(const DeployableFile &file)
.arg(file.remoteFilePath(), process.cleanedStdErr())); .arg(file.remoteFilePath(), process.cleanedStdErr()));
} }
}; };
return ProcessTask(setupHandler, {}, errorHandler); return ProcessTask(onSetup, onError, CallDoneIf::Error);
} }
GroupItem GenericDirectUploadStep::chmodTree(const TreeStorage<UploadStorage> &storage) GroupItem GenericDirectUploadStep::chmodTree(const TreeStorage<UploadStorage> &storage)

View File

@@ -205,7 +205,7 @@ SubversionDiffEditorController::SubversionDiffEditorController(IDocument *docume
ProcessTask(onDescriptionSetup, onDescriptionDone) ProcessTask(onDescriptionSetup, onDescriptionDone)
}, },
Group { Group {
ProcessTask(onDiffSetup, onDiffDone), ProcessTask(onDiffSetup, onDiffDone, CallDoneIf::Success),
postProcessTask(diffInputStorage) postProcessTask(diffInputStorage)
} }
}; };

View File

@@ -127,22 +127,22 @@ void UpdateInfoPlugin::startCheckForUpdates()
checkForUpdatesStopped(); checkForUpdatesStopped();
}; };
const auto setupUpdate = [doSetup](Process &process) { const auto onUpdateSetup = [doSetup](Process &process) {
doSetup(process, {"ch", "-g", "*=false,ifw.package.*=true"}); doSetup(process, {"ch", "-g", "*=false,ifw.package.*=true"});
}; };
const auto updateDone = [this](const Process &process) { const auto onUpdateDone = [this](const Process &process) {
d->m_updateOutput = process.cleanedStdOut(); d->m_updateOutput = process.cleanedStdOut();
}; };
QList<GroupItem> tasks { ProcessTask(setupUpdate, updateDone) }; QList<GroupItem> tasks { ProcessTask(onUpdateSetup, onUpdateDone, CallDoneIf::Success) };
if (d->m_settings.checkForQtVersions) { if (d->m_settings.checkForQtVersions) {
const auto setupPackages = [doSetup](Process &process) { const auto onPackagesSetup = [doSetup](Process &process) {
doSetup(process, {"se", "qt[.]qt[0-9][.][0-9]+$", "-g", "*=false,ifw.package.*=true"}); doSetup(process, {"se", "qt[.]qt[0-9][.][0-9]+$", "-g", "*=false,ifw.package.*=true"});
}; };
const auto packagesDone = [this](const Process &process) { const auto onPackagesDone = [this](const Process &process) {
d->m_packagesOutput = process.cleanedStdOut(); d->m_packagesOutput = process.cleanedStdOut();
}; };
tasks << ProcessTask(setupPackages, packagesDone); tasks << ProcessTask(onPackagesSetup, onPackagesDone, CallDoneIf::Success);
} }
d->m_taskTree.reset(new TaskTree(Group{tasks})); d->m_taskTree.reset(new TaskTree(Group{tasks}));

View File

@@ -203,7 +203,7 @@ Group ValgrindProcessPrivate::runRecipe() const
Group { Group {
onGroupSetup(onParserGroupSetup), onGroupSetup(onParserGroupSetup),
waitForBarrierTask(xmlBarrier), waitForBarrierTask(xmlBarrier),
ParserTask(onParserSetup, {}, onParserError) ParserTask(onParserSetup, onParserError, CallDoneIf::Error)
} }
}; };
return root; return root;

View File

@@ -77,9 +77,9 @@ void tst_Tasking::validConstructs()
{ {
const Group task { const Group task {
parallel, parallel,
TestTask([](TaskObject &) {}, [](const TaskObject &) {}), TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {}),
TestTask([](TaskObject &) {}, [](const TaskObject &) {}), TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {}),
TestTask([](TaskObject &) {}, [](const TaskObject &) {}) TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {})
}; };
const Group group1 { const Group group1 {
@@ -90,18 +90,18 @@ void tst_Tasking::validConstructs()
parallel, parallel,
Group { Group {
parallel, parallel,
TestTask([](TaskObject &) {}, [](const TaskObject &) {}), TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {}),
Group { Group {
parallel, parallel,
TestTask([](TaskObject &) {}, [](const TaskObject &) {}), TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {}),
Group { Group {
parallel, parallel,
TestTask([](TaskObject &) {}, [](const TaskObject &) {}) TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {})
} }
}, },
Group { Group {
parallel, parallel,
TestTask([](TaskObject &) {}, [](const TaskObject &) {}), TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {}),
onGroupDone([] {}) onGroupDone([] {})
} }
}, },
@@ -119,14 +119,12 @@ void tst_Tasking::validConstructs()
parallel, parallel,
TestTask(), TestTask(),
TestTask(setupHandler), TestTask(setupHandler),
TestTask(setupHandler, finishHandler), TestTask(setupHandler, finishHandler, CallDoneIf::Success),
TestTask(setupHandler, finishHandler, errorHandler),
TestTask(setupHandler, doneHandler), TestTask(setupHandler, doneHandler),
// need to explicitly pass empty handler for done // need to explicitly pass empty handler for done
TestTask(setupHandler, {}, errorHandler), TestTask(setupHandler, errorHandler, CallDoneIf::Error),
TestTask({}, finishHandler), TestTask({}, finishHandler, CallDoneIf::Success),
TestTask({}, finishHandler, errorHandler), TestTask({}, errorHandler, CallDoneIf::Error)
TestTask({}, {}, errorHandler)
}; };
// When turning each of below blocks on, you should see the specific compiler error message. // When turning each of below blocks on, you should see the specific compiler error message.

View File

@@ -434,10 +434,10 @@ void tst_Async::taskTree()
}; };
const Group root { const Group root {
AsyncTask<int>(setupIntAsync, handleIntAsync), AsyncTask<int>(setupIntAsync, handleIntAsync, CallDoneIf::Success),
AsyncTask<int>(setupIntAsync, handleIntAsync), AsyncTask<int>(setupIntAsync, handleIntAsync, CallDoneIf::Success),
AsyncTask<int>(setupIntAsync, handleIntAsync), AsyncTask<int>(setupIntAsync, handleIntAsync, CallDoneIf::Success),
AsyncTask<int>(setupIntAsync, handleIntAsync), AsyncTask<int>(setupIntAsync, handleIntAsync, CallDoneIf::Success),
}; };
@@ -506,11 +506,11 @@ void tst_Async::mapReduce_data()
return Group { return Group {
executeMode, executeMode,
onGroupSetup(initTree), onGroupSetup(initTree),
AsyncTask<int>(std::bind(setupHandler, _1, 1), handleAsync), AsyncTask<int>(std::bind(setupHandler, _1, 1), handleAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupHandler, _1, 2), handleAsync), AsyncTask<int>(std::bind(setupHandler, _1, 2), handleAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupHandler, _1, 3), handleAsync), AsyncTask<int>(std::bind(setupHandler, _1, 3), handleAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupHandler, _1, 4), handleAsync), AsyncTask<int>(std::bind(setupHandler, _1, 4), handleAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupHandler, _1, 5), handleAsync), AsyncTask<int>(std::bind(setupHandler, _1, 5), handleAsync, CallDoneIf::Success),
onGroupDone(doneHandler) onGroupDone(doneHandler)
}; };
}; };
@@ -542,9 +542,9 @@ void tst_Async::mapReduce_data()
const Group simpleRoot = { const Group simpleRoot = {
sequential, sequential,
onGroupSetup([] { s_sum = 0; }), onGroupSetup([] { s_sum = 0; }),
AsyncTask<int>(std::bind(setupSimpleAsync, _1, 1), handleSimpleAsync), AsyncTask<int>(std::bind(setupSimpleAsync, _1, 1), handleSimpleAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupSimpleAsync, _1, 2), handleSimpleAsync), AsyncTask<int>(std::bind(setupSimpleAsync, _1, 2), handleSimpleAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupSimpleAsync, _1, 3), handleSimpleAsync) AsyncTask<int>(std::bind(setupSimpleAsync, _1, 3), handleSimpleAsync, CallDoneIf::Success)
}; };
QTest::newRow("Simple") << simpleRoot << 3.0 << QList<double>({.5, 1.5, 3.}); QTest::newRow("Simple") << simpleRoot << 3.0 << QList<double>({.5, 1.5, 3.});
@@ -557,9 +557,9 @@ void tst_Async::mapReduce_data()
const Group stringRoot = { const Group stringRoot = {
parallel, parallel,
onGroupSetup([] { s_sum = 90.0; }), onGroupSetup([] { s_sum = 90.0; }),
AsyncTask<int>(std::bind(setupStringAsync, _1, "blubb"), handleStringAsync), AsyncTask<int>(std::bind(setupStringAsync, _1, "blubb"), handleStringAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupStringAsync, _1, "foo"), handleStringAsync), AsyncTask<int>(std::bind(setupStringAsync, _1, "foo"), handleStringAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupStringAsync, _1, "blah"), handleStringAsync) AsyncTask<int>(std::bind(setupStringAsync, _1, "blah"), handleStringAsync, CallDoneIf::Success)
}; };
QTest::newRow("String") << stringRoot << 1.5 << QList<double>({}); QTest::newRow("String") << stringRoot << 1.5 << QList<double>({});
} }