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 {
finishAllAndError,
TimeoutTask([timeout](milliseconds &timeoutData) { timeoutData = timeout; },
taskHandler)
taskHandler, CallDoneIf::Success)
},
item
};
@@ -1483,9 +1483,16 @@ void TaskNode::stop()
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)
{
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);
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.
// 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).
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).
@@ -131,6 +132,14 @@ enum class SetupResult
};
Q_ENUM_NS(SetupResult);
enum class CallDoneIf
{
SuccessOrError,
Success,
Error
};
Q_ENUM_NS(CallDoneIf);
class TASKING_EXPORT GroupItem
{
public:
@@ -149,6 +158,7 @@ public:
TaskCreateHandler m_createHandler;
TaskSetupHandler m_setupHandler = {};
TaskDoneHandler m_doneHandler = {};
CallDoneIf m_callDoneIf = CallDoneIf::SuccessOrError;
};
struct GroupHandler {
@@ -330,13 +340,15 @@ public:
static Adapter *createAdapter() { return new Adapter; }
CustomTask() : GroupItem({&createAdapter}) {}
template <typename SetupHandler = SetupFunction>
CustomTask(SetupHandler &&setup, const EndFunction &done = {}, const EndFunction &error = {})
: GroupItem({&createAdapter, wrapSetup(std::forward<SetupHandler>(setup)),
wrapEnds(done, error)}) {}
CustomTask(SetupHandler &&setup, const EndFunction &done, CallDoneIf callDoneIf)
: GroupItem({&createAdapter, wrapSetup(std::forward<SetupHandler>(setup)), wrapEnd(done),
callDoneIf}) {}
template <typename SetupHandler>
CustomTask(SetupHandler &&setup, const DoneFunction &done)
: GroupItem({&createAdapter, wrapSetup(std::forward<SetupHandler>(setup)), wrapDone(done)})
CustomTask(SetupHandler &&setup, const DoneFunction &done = {},
CallDoneIf callDoneIf = CallDoneIf::SuccessOrError)
: GroupItem({&createAdapter, wrapSetup(std::forward<SetupHandler>(setup)), wrapDone(done),
callDoneIf})
{}
GroupItem withTimeout(std::chrono::milliseconds timeout,
@@ -365,14 +377,12 @@ private:
};
};
static TaskDoneHandler wrapEnds(const EndFunction &doneHandler, const EndFunction &errorHandler) {
if (!doneHandler && !errorHandler)
static TaskDoneHandler wrapEnd(const EndFunction &handler) {
if (!handler)
return {};
return [doneHandler, errorHandler](const TaskInterface &taskInterface, bool success) {
return [handler](const TaskInterface &taskInterface, bool) {
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.";
QList<GroupItem> tasks{parallelLimit(limit)};
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.setPriority(QThread::LowestPriority);
async.setFutureSynchronizer(&m_futureSynchronizer);
@@ -387,7 +387,7 @@ void TestCodeParser::scanForTests(const QSet<FilePath> &filePaths,
for (const TestParseResultPtr &result : results)
emit testParseResultReady(result);
};
tasks.append(AsyncTask<TestParseResultPtr>(setup, onDone));
tasks.append(AsyncTask<TestParseResultPtr>(onSetup, onDone, CallDoneIf::Success));
}
m_taskTree.reset(new TaskTree{tasks});
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; }));
}
LocatorMatcherTask currentDocumentMatcher()
static LocatorMatcherTask currentDocumentMatcher()
{
using namespace Tasking;
@@ -193,7 +193,7 @@ LocatorMatcherTask currentDocumentMatcher()
const Group root {
Tasking::Storage(resultStorage),
CurrentDocumentSymbolsRequestTask(onQuerySetup, onQueryDone),
CurrentDocumentSymbolsRequestTask(onQuerySetup, onQueryDone, CallDoneIf::Success),
AsyncTask<void>(onFilterSetup)
};
return {root, storage};

View File

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

View File

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

View File

@@ -88,18 +88,18 @@ DirectoryFilter::DirectoryFilter(Id id)
m_cache.setFilePaths({});
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.setConcurrentCallData(&refresh, m_directories, m_filters, m_exclusionFilters,
displayName());
};
const auto asyncDone = [this](const Async<FilePaths> &async) {
const auto onDone = [this](const Async<FilePaths> &async) {
if (async.isResultAvailable())
m_cache.setFilePaths(async.result());
};
const Group root {
onGroupSetup(groupSetup),
AsyncTask<FilePaths>(asyncSetup, asyncDone)
AsyncTask<FilePaths>(onSetup, onDone, CallDoneIf::Success)
};
setRefreshRecipe(root);
}

View File

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

View File

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

View File

@@ -52,7 +52,7 @@ void CppProjectUpdater::update(const ProjectUpdateInfo &projectUpdateInfo,
ProjectInfo::ConstPtr projectInfo = nullptr;
};
const TreeStorage<UpdateStorage> storage;
const auto setupInfoGenerator = [=](Async<ProjectInfo::ConstPtr> &async) {
const auto onInfoGeneratorSetup = [=](Async<ProjectInfo::ConstPtr> &async) {
async.setConcurrentCallData(infoGenerator);
async.setFutureSynchronizer(&m_futureSynchronizer);
};
@@ -61,7 +61,8 @@ void CppProjectUpdater::update(const ProjectUpdateInfo &projectUpdateInfo,
storage->projectInfo = async.result();
};
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) {
if (compiler && compiler->isDirty())
tasks.append(compiler->compileFileItem());

View File

@@ -252,12 +252,14 @@ void AttachCoreDialog::accepted()
parallel,
AsyncTask<ResultType>{[=](auto &task) {
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) {
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);

View File

@@ -118,7 +118,7 @@ DiffFilesController::DiffFilesController(IDocument *document)
QList<GroupItem> tasks { parallel, finishAllAndDone };
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(
DiffFile(ignoreWhitespace(), contextLineCount()), reloadInput);
async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer());
@@ -128,7 +128,7 @@ DiffFilesController::DiffFilesController(IDocument *document)
if (async.isResultAvailable())
(*outputList)[i] = async.result();
};
tasks.append(AsyncTask<FileData>(setupDiff, onDiffDone));
tasks.append(AsyncTask<FileData>(onDiffSetup, onDiffDone, CallDoneIf::Success));
}
taskTree.setRecipe(tasks);
};

View File

@@ -547,7 +547,7 @@ TaskTree *BranchView::onFastForwardMerge(const std::function<void()> &callback)
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});
};
const auto onMergeBaseDone = [storage](const Process &process) {
@@ -563,7 +563,7 @@ TaskTree *BranchView::onFastForwardMerge(const std::function<void()> &callback)
const Group root {
Tasking::Storage(storage),
parallel,
ProcessTask(setupMergeBase, onMergeBaseDone),
ProcessTask(onMergeBaseSetup, onMergeBaseDone, CallDoneIf::Success),
topRevisionProc,
onGroupDone([storage, callback] {
if (storage->mergeBase == storage->topRevision)

View File

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

View File

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

View File

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

View File

@@ -328,14 +328,14 @@ ProcessExtraCompiler::ProcessExtraCompiler(const Project *project, const FilePat
GroupItem ProcessExtraCompiler::taskItemImpl(const ContentProvider &provider)
{
const auto setupTask = [=](Async<FileNameToContentsHash> &async) {
const auto onSetup = [=](Async<FileNameToContentsHash> &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 Async<FileNameToContentsHash> &async) {
const auto onDone = [=](const Async<FileNameToContentsHash> &async) {
if (!async.isResultAvailable())
return;
const FileNameToContentsHash data = async.result();
@@ -345,7 +345,7 @@ GroupItem ProcessExtraCompiler::taskItemImpl(const ContentProvider &provider)
setContent(it.key(), it.value());
updateCompileTime();
};
return AsyncTask<FileNameToContentsHash>(setupTask, taskDone);
return AsyncTask<FileNameToContentsHash>(onSetup, onDone, CallDoneIf::Success);
}
FilePath ProcessExtraCompiler::workingDirectory() const

View File

@@ -147,24 +147,24 @@ GroupItem QnxDeployQtLibrariesDialogPrivate::checkDirTask()
GroupItem QnxDeployQtLibrariesDialogPrivate::removeDirTask()
{
const auto setupHandler = [this](Process &process) {
const auto onSetup = [this](Process &process) {
if (m_checkResult != CheckResult::RemoveDir)
return SetupResult::StopWithDone;
m_deployLogWindow->appendPlainText(Tr::tr("Removing \"%1\"").arg(fullRemoteDirectory()));
process.setCommand({m_device->filePath("rm"), {"-rf", fullRemoteDirectory()}});
return SetupResult::Continue;
};
const auto errorHandler = [this](const Process &process) {
const auto onError = [this](const Process &process) {
QTC_ASSERT(process.exitCode() == 0, return);
m_deployLogWindow->appendPlainText(Tr::tr("Connection failed: %1")
.arg(process.errorString()));
};
return ProcessTask(setupHandler, {}, errorHandler);
return ProcessTask(onSetup, onError, CallDoneIf::Error);
}
GroupItem QnxDeployQtLibrariesDialogPrivate::uploadTask()
{
const auto setupHandler = [this](FileTransfer &transfer) {
const auto onSetup = [this](FileTransfer &transfer) {
if (m_deployableFiles.isEmpty()) {
emitProgressMessage(Tr::tr("No files need to be uploaded."));
return SetupResult::StopWithDone;
@@ -190,19 +190,19 @@ GroupItem QnxDeployQtLibrariesDialogPrivate::uploadTask()
this, &QnxDeployQtLibrariesDialogPrivate::emitProgressMessage);
return SetupResult::Continue;
};
const auto errorHandler = [this](const FileTransfer &transfer) {
const auto onError = [this](const FileTransfer &transfer) {
emitErrorMessage(transfer.resultData().m_errorString);
};
return FileTransferTask(setupHandler, {}, errorHandler);
return FileTransferTask(onSetup, onError, CallDoneIf::Error);
}
GroupItem QnxDeployQtLibrariesDialogPrivate::chmodTask(const DeployableFile &file)
{
const auto setupHandler = [=](Process &process) {
const auto onSetup = [=](Process &process) {
process.setCommand({m_device->filePath("chmod"),
{"a+x", Utils::ProcessArgs::quoteArgUnix(file.remoteFilePath())}});
};
const auto errorHandler = [=](const Process &process) {
const auto onError = [=](const Process &process) {
const QString error = process.errorString();
if (!error.isEmpty()) {
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()));
}
};
return ProcessTask(setupHandler, {}, errorHandler);
return ProcessTask(onSetup, onError, CallDoneIf::Error);
}
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);
emit errorMessage(message + '\n');
};
setExtraTests({ProcessTask(onSetup, onDone)});
setExtraTests({ProcessTask(onSetup, onDone, CallDoneIf::Success)});
RemoteLinux::GenericLinuxDeviceTester::testDevice(device);
}

View File

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

View File

@@ -443,32 +443,32 @@ void FileSystemAccessTest::testFileStreamer()
return FileStreamerTask(setup);
};
const auto localReader = [&] {
const auto setup = [&](FileStreamer &streamer) {
const auto onSetup = [&](FileStreamer &streamer) {
streamer.setStreamMode(StreamMode::Reader);
streamer.setSource(localSourcePath);
};
const auto onDone = [&](const FileStreamer &streamer) {
localData = streamer.readData();
};
return FileStreamerTask(setup, onDone);
return FileStreamerTask(onSetup, onDone, CallDoneIf::Success);
};
const auto remoteReader = [&] {
const auto setup = [&](FileStreamer &streamer) {
const auto onSetup = [&](FileStreamer &streamer) {
streamer.setStreamMode(StreamMode::Reader);
streamer.setSource(remoteSourcePath);
};
const auto onDone = [&](const FileStreamer &streamer) {
remoteData = streamer.readData();
};
return FileStreamerTask(setup, onDone);
return FileStreamerTask(onSetup, onDone, CallDoneIf::Success);
};
const auto transfer = [](const FilePath &source, const FilePath &dest,
std::optional<QByteArray> *result) {
const auto setupTransfer = [=](FileStreamer &streamer) {
const auto onTransferSetup = [=](FileStreamer &streamer) {
streamer.setSource(source);
streamer.setDestination(dest);
};
const auto setupReader = [=](FileStreamer &streamer) {
const auto onReaderSetup = [=](FileStreamer &streamer) {
streamer.setStreamMode(StreamMode::Reader);
streamer.setSource(dest);
};
@@ -476,8 +476,8 @@ void FileSystemAccessTest::testFileStreamer()
*result = streamer.readData();
};
const Group root {
FileStreamerTask(setupTransfer),
FileStreamerTask(setupReader, onReaderDone)
FileStreamerTask(onTransferSetup),
FileStreamerTask(onReaderSetup, onReaderDone, CallDoneIf::Success)
};
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)
@@ -135,7 +135,7 @@ static FileTransferMethod supportedTransferMethodFor(const FileToTransfer &fileT
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;
if (method() == 0)
preferredTransferMethod = FileTransferMethod::Rsync;
@@ -164,7 +164,7 @@ GroupItem GenericDeployStep::transferTask(const TreeStorage<FilesToTransfer> &st
transfer.setFilesToTransfer(*storage);
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();
if (result.m_error == QProcess::FailedToStart) {
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);
}
};
return FileTransferTask(setupHandler, {}, errorHandler);
return FileTransferTask(onSetup, onError, CallDoneIf::Error);
}
GroupItem GenericDeployStep::deployRecipe()

View File

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

View File

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

View File

@@ -127,22 +127,22 @@ void UpdateInfoPlugin::startCheckForUpdates()
checkForUpdatesStopped();
};
const auto setupUpdate = [doSetup](Process &process) {
const auto onUpdateSetup = [doSetup](Process &process) {
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();
};
QList<GroupItem> tasks { ProcessTask(setupUpdate, updateDone) };
QList<GroupItem> tasks { ProcessTask(onUpdateSetup, onUpdateDone, CallDoneIf::Success) };
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"});
};
const auto packagesDone = [this](const Process &process) {
const auto onPackagesDone = [this](const Process &process) {
d->m_packagesOutput = process.cleanedStdOut();
};
tasks << ProcessTask(setupPackages, packagesDone);
tasks << ProcessTask(onPackagesSetup, onPackagesDone, CallDoneIf::Success);
}
d->m_taskTree.reset(new TaskTree(Group{tasks}));

View File

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

View File

@@ -77,9 +77,9 @@ void tst_Tasking::validConstructs()
{
const Group task {
parallel,
TestTask([](TaskObject &) {}, [](const TaskObject &) {}),
TestTask([](TaskObject &) {}, [](const TaskObject &) {}),
TestTask([](TaskObject &) {}, [](const TaskObject &) {})
TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {}),
TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {}),
TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {})
};
const Group group1 {
@@ -90,18 +90,18 @@ void tst_Tasking::validConstructs()
parallel,
Group {
parallel,
TestTask([](TaskObject &) {}, [](const TaskObject &) {}),
TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {}),
Group {
parallel,
TestTask([](TaskObject &) {}, [](const TaskObject &) {}),
TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {}),
Group {
parallel,
TestTask([](TaskObject &) {}, [](const TaskObject &) {})
TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {})
}
},
Group {
parallel,
TestTask([](TaskObject &) {}, [](const TaskObject &) {}),
TestTask([](TaskObject &) {}, [](const TaskObject &, bool) {}),
onGroupDone([] {})
}
},
@@ -119,14 +119,12 @@ void tst_Tasking::validConstructs()
parallel,
TestTask(),
TestTask(setupHandler),
TestTask(setupHandler, finishHandler),
TestTask(setupHandler, finishHandler, errorHandler),
TestTask(setupHandler, finishHandler, CallDoneIf::Success),
TestTask(setupHandler, doneHandler),
// need to explicitly pass empty handler for done
TestTask(setupHandler, {}, errorHandler),
TestTask({}, finishHandler),
TestTask({}, finishHandler, errorHandler),
TestTask({}, {}, errorHandler)
TestTask(setupHandler, errorHandler, CallDoneIf::Error),
TestTask({}, finishHandler, CallDoneIf::Success),
TestTask({}, errorHandler, CallDoneIf::Error)
};
// 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 {
AsyncTask<int>(setupIntAsync, handleIntAsync),
AsyncTask<int>(setupIntAsync, handleIntAsync),
AsyncTask<int>(setupIntAsync, handleIntAsync),
AsyncTask<int>(setupIntAsync, handleIntAsync),
AsyncTask<int>(setupIntAsync, handleIntAsync, CallDoneIf::Success),
AsyncTask<int>(setupIntAsync, handleIntAsync, CallDoneIf::Success),
AsyncTask<int>(setupIntAsync, handleIntAsync, CallDoneIf::Success),
AsyncTask<int>(setupIntAsync, handleIntAsync, CallDoneIf::Success),
};
@@ -506,11 +506,11 @@ void tst_Async::mapReduce_data()
return Group {
executeMode,
onGroupSetup(initTree),
AsyncTask<int>(std::bind(setupHandler, _1, 1), handleAsync),
AsyncTask<int>(std::bind(setupHandler, _1, 2), handleAsync),
AsyncTask<int>(std::bind(setupHandler, _1, 3), handleAsync),
AsyncTask<int>(std::bind(setupHandler, _1, 4), handleAsync),
AsyncTask<int>(std::bind(setupHandler, _1, 5), handleAsync),
AsyncTask<int>(std::bind(setupHandler, _1, 1), handleAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupHandler, _1, 2), handleAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupHandler, _1, 3), handleAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupHandler, _1, 4), handleAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupHandler, _1, 5), handleAsync, CallDoneIf::Success),
onGroupDone(doneHandler)
};
};
@@ -542,9 +542,9 @@ void tst_Async::mapReduce_data()
const Group simpleRoot = {
sequential,
onGroupSetup([] { s_sum = 0; }),
AsyncTask<int>(std::bind(setupSimpleAsync, _1, 1), handleSimpleAsync),
AsyncTask<int>(std::bind(setupSimpleAsync, _1, 2), handleSimpleAsync),
AsyncTask<int>(std::bind(setupSimpleAsync, _1, 3), handleSimpleAsync)
AsyncTask<int>(std::bind(setupSimpleAsync, _1, 1), handleSimpleAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupSimpleAsync, _1, 2), handleSimpleAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupSimpleAsync, _1, 3), handleSimpleAsync, CallDoneIf::Success)
};
QTest::newRow("Simple") << simpleRoot << 3.0 << QList<double>({.5, 1.5, 3.});
@@ -557,9 +557,9 @@ void tst_Async::mapReduce_data()
const Group stringRoot = {
parallel,
onGroupSetup([] { s_sum = 90.0; }),
AsyncTask<int>(std::bind(setupStringAsync, _1, "blubb"), handleStringAsync),
AsyncTask<int>(std::bind(setupStringAsync, _1, "foo"), handleStringAsync),
AsyncTask<int>(std::bind(setupStringAsync, _1, "blah"), handleStringAsync)
AsyncTask<int>(std::bind(setupStringAsync, _1, "blubb"), handleStringAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupStringAsync, _1, "foo"), handleStringAsync, CallDoneIf::Success),
AsyncTask<int>(std::bind(setupStringAsync, _1, "blah"), handleStringAsync, CallDoneIf::Success)
};
QTest::newRow("String") << stringRoot << 1.5 << QList<double>({});
}