TaskTree: Rename optional into finishAllAndDone

Rationale:
1. More descriptive.
2. More consistent with a planned new finishAllAndError policy.
3. Limits the possibilities of making a conflict with std::optional.

Change-Id: I5155630188e4b699e6c18b13a101e0e2d4fe98f2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2023-05-28 17:20:55 +02:00
parent ffdb0c7dcc
commit 4e01ca18d1
16 changed files with 39 additions and 39 deletions

View File

@@ -164,7 +164,7 @@ private:
Constructs a group's element holding the group done handler. Constructs a group's element holding the group done handler.
The \a handler is invoked whenever the group finishes with success. The \a handler is invoked whenever the group finishes with success.
Depending on the group's workflow policy, this handler may also be called Depending on the group's workflow policy, this handler may also be called
when the running group is stopped (e.g. when optional element was used). when the running group is stopped (e.g. when finishAllAndDone element was used).
When the \a handler is invoked, all of the group's child tasks are already finished. When the \a handler is invoked, all of the group's child tasks are already finished.
@@ -256,7 +256,7 @@ const TaskItem continueOnError = workflowPolicy(WorkflowPolicy::ContinueOnError)
const TaskItem stopOnDone = workflowPolicy(WorkflowPolicy::StopOnDone); const TaskItem stopOnDone = workflowPolicy(WorkflowPolicy::StopOnDone);
const TaskItem continueOnDone = workflowPolicy(WorkflowPolicy::ContinueOnDone); const TaskItem continueOnDone = workflowPolicy(WorkflowPolicy::ContinueOnDone);
const TaskItem stopOnFinished = workflowPolicy(WorkflowPolicy::StopOnFinished); const TaskItem stopOnFinished = workflowPolicy(WorkflowPolicy::StopOnFinished);
const TaskItem optional = workflowPolicy(WorkflowPolicy::Optional); const TaskItem finishAllAndDone = workflowPolicy(WorkflowPolicy::FinishAllAndDone);
static TaskAction toTaskAction(bool success) static TaskAction toTaskAction(bool success)
{ {
@@ -720,7 +720,7 @@ TaskContainer::RuntimeData::~RuntimeData()
bool TaskContainer::RuntimeData::updateSuccessBit(bool success) bool TaskContainer::RuntimeData::updateSuccessBit(bool success)
{ {
if (m_constData.m_workflowPolicy == WorkflowPolicy::Optional) if (m_constData.m_workflowPolicy == WorkflowPolicy::FinishAllAndDone)
return m_successBit; return m_successBit;
if (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnFinished) { if (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnFinished) {
m_successBit = success; m_successBit = success;
@@ -1394,7 +1394,7 @@ void TaskNode::invokeEndHandler(bool success)
In sequential mode, only the first task is started, and when finished, In sequential mode, only the first task is started, and when finished,
the group finishes too, so the other tasks are ignored. the group finishes too, so the other tasks are ignored.
\row \row
\li optional \li finishAllAndDone
\li The group executes all tasks and ignores their return state. When all \li The group executes all tasks and ignores their return state. When all
tasks finish, the group finishes with success. tasks finish, the group finishes with success.
\endtable \endtable

View File

@@ -99,7 +99,7 @@ private:
// b) On first done - continue executing all children and report done afterwards. // b) On first done - continue executing all children and report done afterwards.
// 3. Stops on first finished child. In sequential mode it will never run other children then the first one. // 3. Stops on first finished child. In sequential mode it will never run other children then the first one.
// Useful only in parallel mode. // Useful only in parallel mode.
// 4. Always run all children, ignore their result and report done afterwards. // 4. Always run all children, let them finish, ignore their results and report done 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).
@@ -107,7 +107,7 @@ enum class WorkflowPolicy {
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).
ContinueOnDone, // 2b - The same, but children execution continues. Reports error when no children. ContinueOnDone, // 2b - The same, but children execution continues. Reports error when no children.
StopOnFinished, // 3 - Stops on first finished child and report its result. StopOnFinished, // 3 - Stops on first finished child and report its result.
Optional // 4 - Reports done after all children finished. FinishAllAndDone // 4 - Reports done after all children finished.
}; };
enum class TaskAction enum class TaskAction
@@ -248,7 +248,7 @@ TASKING_EXPORT extern const TaskItem continueOnError;
TASKING_EXPORT extern const TaskItem stopOnDone; TASKING_EXPORT extern const TaskItem stopOnDone;
TASKING_EXPORT extern const TaskItem continueOnDone; TASKING_EXPORT extern const TaskItem continueOnDone;
TASKING_EXPORT extern const TaskItem stopOnFinished; TASKING_EXPORT extern const TaskItem stopOnFinished;
TASKING_EXPORT extern const TaskItem optional; TASKING_EXPORT extern const TaskItem finishAllAndDone;
class TASKING_EXPORT Storage : public TaskItem class TASKING_EXPORT Storage : public TaskItem
{ {

View File

@@ -347,7 +347,7 @@ void TestRunner::runTestsHelper()
std::unique_ptr<TestOutputReader> m_outputReader; std::unique_ptr<TestOutputReader> m_outputReader;
}; };
QList<TaskItem> tasks{optional}; QList<TaskItem> tasks{finishAllAndDone};
for (ITestConfiguration *config : m_selectedTests) { for (ITestConfiguration *config : m_selectedTests) {
QTC_ASSERT(config, continue); QTC_ASSERT(config, continue);
@@ -442,7 +442,7 @@ void TestRunner::runTestsHelper()
} }
}; };
const Group group { const Group group {
optional, finishAllAndDone,
Storage(storage), Storage(storage),
onGroupSetup(onSetup), onGroupSetup(onSetup),
ProcessTask(onProcessSetup, onProcessDone, onProcessDone) ProcessTask(onProcessSetup, onProcessDone, onProcessDone)

View File

@@ -186,7 +186,7 @@ TaskItem clangToolTask(const AnalyzeInputData &input,
Storage(storage), Storage(storage),
onGroupSetup(onSetup), onGroupSetup(onSetup),
Group { Group {
optional, finishAllAndDone,
ProcessTask(onProcessSetup, onProcessDone, onProcessError) ProcessTask(onProcessSetup, onProcessDone, onProcessError)
} }
}; };

View File

@@ -209,7 +209,7 @@ void DocumentClangToolRunner::run()
return !m_document->isModified() || isVFSOverlaySupported(executable); return !m_document->isModified() || isVFSOverlaySupported(executable);
}; };
const auto outputHandler = [this](const AnalyzeOutputData &output) { onDone(output); }; const auto outputHandler = [this](const AnalyzeOutputData &output) { onDone(output); };
tasks.append(Group{optional, clangToolTask(input, setupHandler, outputHandler)}); tasks.append(Group{finishAllAndDone, clangToolTask(input, setupHandler, outputHandler)});
}; };
addClangTool(ClangToolType::Tidy); addClangTool(ClangToolType::Tidy);
addClangTool(ClangToolType::Clazy); addClangTool(ClangToolType::Clazy);

View File

@@ -470,7 +470,7 @@ void LocatorMatcher::start()
for (const LocatorMatcherTask &task : std::as_const(d->m_tasks)) { for (const LocatorMatcherTask &task : std::as_const(d->m_tasks)) {
const auto storage = task.storage; const auto storage = task.storage;
const Group group { const Group group {
optional, finishAllAndDone,
Storage(storage), Storage(storage),
onGroupSetup(onSetup(storage, index)), onGroupSetup(onSetup(storage, index)),
onGroupDone(onDone(storage)), onGroupDone(onDone(storage)),

View File

@@ -388,7 +388,7 @@ void Locator::refresh(const QList<ILocatorFilter *> &filters)
continue; continue;
const Group group { const Group group {
optional, finishAllAndDone,
*task, *task,
onGroupDone([this, filter] { m_refreshingFilters.removeOne(filter); }) onGroupDone([this, filter] { m_refreshingFilters.removeOne(filter); })
}; };

View File

@@ -128,7 +128,7 @@ DiffFilesController::DiffFilesController(IDocument *document)
outputList->resize(inputList.size()); outputList->resize(inputList.size());
using namespace std::placeholders; using namespace std::placeholders;
QList<TaskItem> tasks {parallel, optional}; QList<TaskItem> tasks {parallel, finishAllAndDone};
for (int i = 0; i < inputList.size(); ++i) { for (int i = 0; i < inputList.size(); ++i) {
tasks.append(AsyncTask<FileData>(std::bind(setupDiff, _1, inputList.at(i)), tasks.append(AsyncTask<FileData>(std::bind(setupDiff, _1, inputList.at(i)),
std::bind(onDiffDone, _1, i))); std::bind(onDiffDone, _1, i)));

View File

@@ -465,11 +465,11 @@ ShowController::ShowController(IDocument *document, const QString &id)
parallel, parallel,
onGroupSetup([this] { setStartupFile(VcsBase::source(this->document()).toString()); }), onGroupSetup([this] { setStartupFile(VcsBase::source(this->document()).toString()); }),
Group { Group {
optional, finishAllAndDone,
ProcessTask(setupDescription, onDescriptionDone), ProcessTask(setupDescription, onDescriptionDone),
Group { Group {
parallel, parallel,
optional, finishAllAndDone,
onGroupSetup(desciptionDetailsSetup), onGroupSetup(desciptionDetailsSetup),
ProcessTask(setupBranches, onBranchesDone, onBranchesError), ProcessTask(setupBranches, onBranchesDone, onBranchesError),
ProcessTask(setupPrecedes, onPrecedesDone, onPrecedesError), ProcessTask(setupPrecedes, onPrecedesDone, onPrecedesError),

View File

@@ -223,7 +223,7 @@ TaskItem QnxDeployQtLibrariesDialogPrivate::chmodTree()
if (file.isExecutable()) if (file.isExecutable())
filesToChmod << file; filesToChmod << file;
} }
QList<TaskItem> chmodList{optional, parallelLimit(MaxConcurrentStatCalls)}; QList<TaskItem> chmodList{finishAllAndDone, parallelLimit(MaxConcurrentStatCalls)};
for (const DeployableFile &file : std::as_const(filesToChmod)) { for (const DeployableFile &file : std::as_const(filesToChmod)) {
QTC_ASSERT(file.isValid(), continue); QTC_ASSERT(file.isValid(), continue);
chmodList.append(chmodTask(file)); chmodList.append(chmodTask(file));
@@ -263,7 +263,7 @@ Group QnxDeployQtLibrariesDialogPrivate::deployRecipe()
const Group root { const Group root {
onGroupSetup(setupHandler), onGroupSetup(setupHandler),
Group { Group {
optional, finishAllAndDone,
checkDirTask() checkDirTask()
}, },
Group { Group {

View File

@@ -179,7 +179,7 @@ TaskItem GenericDirectUploadStep::statTree(const TreeStorage<UploadStorage> &sto
const auto setupHandler = [=](TaskTree &tree) { const auto setupHandler = [=](TaskTree &tree) {
UploadStorage *storagePtr = storage.activeStorage(); UploadStorage *storagePtr = storage.activeStorage();
const QList<DeployableFile> files = filesToStat(storagePtr); const QList<DeployableFile> files = filesToStat(storagePtr);
QList<TaskItem> statList{optional, parallelLimit(MaxConcurrentStatCalls)}; QList<TaskItem> statList{finishAllAndDone, parallelLimit(MaxConcurrentStatCalls)};
for (const DeployableFile &file : std::as_const(files)) { for (const DeployableFile &file : std::as_const(files)) {
QTC_ASSERT(file.isValid(), continue); QTC_ASSERT(file.isValid(), continue);
statList.append(statTask(storagePtr, file, statEndHandler)); statList.append(statTask(storagePtr, file, statEndHandler));
@@ -256,7 +256,7 @@ TaskItem GenericDirectUploadStep::chmodTree(const TreeStorage<UploadStorage> &st
if (file.isExecutable()) if (file.isExecutable())
filesToChmod << file; filesToChmod << file;
} }
QList<TaskItem> chmodList{optional, parallelLimit(MaxConcurrentStatCalls)}; QList<TaskItem> chmodList{finishAllAndDone, parallelLimit(MaxConcurrentStatCalls)};
for (const DeployableFile &file : std::as_const(filesToChmod)) { for (const DeployableFile &file : std::as_const(filesToChmod)) {
QTC_ASSERT(file.isValid(), continue); QTC_ASSERT(file.isValid(), continue);
chmodList.append(chmodTask(file)); chmodList.append(chmodTask(file));

View File

@@ -131,7 +131,7 @@ TaskItem GenericLinuxDeviceTesterPrivate::unameTask() const
emit q->errorMessage(Tr::tr("uname failed.") + '\n'); emit q->errorMessage(Tr::tr("uname failed.") + '\n');
}; };
return Group { return Group {
optional, finishAllAndDone,
ProcessTask(setup, done, error) ProcessTask(setup, done, error)
}; };
} }
@@ -159,7 +159,7 @@ TaskItem GenericLinuxDeviceTesterPrivate::gathererTask() const
}; };
return Group { return Group {
optional, finishAllAndDone,
DeviceUsedPortsGathererTask(setup, done, error) DeviceUsedPortsGathererTask(setup, done, error)
}; };
} }

View File

@@ -204,7 +204,7 @@ SubversionDiffEditorController::SubversionDiffEditorController(IDocument *docume
Storage(diffInputStorage), Storage(diffInputStorage),
parallel, parallel,
Group { Group {
optional, finishAllAndDone,
ProcessTask(setupDescription, onDescriptionDone, onDescriptionError) ProcessTask(setupDescription, onDescriptionDone, onDescriptionError)
}, },
Group { Group {

View File

@@ -654,7 +654,7 @@ void tst_Tasking::testTree_data()
const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); const Group root5 = createRoot(WorkflowPolicy::StopOnFinished);
QTest::newRow("EmptyStopOnFinished") << TestData{storage, root5, log, 0, OnDone::Success}; QTest::newRow("EmptyStopOnFinished") << TestData{storage, root5, log, 0, OnDone::Success};
const Group root6 = createRoot(WorkflowPolicy::Optional); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndDone);
QTest::newRow("EmptyOptional") << TestData{storage, root6, log, 0, OnDone::Success}; QTest::newRow("EmptyOptional") << TestData{storage, root6, log, 0, OnDone::Success};
} }
@@ -691,7 +691,7 @@ void tst_Tasking::testTree_data()
const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); const Group root5 = createRoot(WorkflowPolicy::StopOnFinished);
QTest::newRow("DoneStopOnFinished") << TestData{storage, root5, log, 1, OnDone::Success}; QTest::newRow("DoneStopOnFinished") << TestData{storage, root5, log, 1, OnDone::Success};
const Group root6 = createRoot(WorkflowPolicy::Optional); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndDone);
QTest::newRow("DoneOptional") << TestData{storage, root6, log, 1, OnDone::Success}; QTest::newRow("DoneOptional") << TestData{storage, root6, log, 1, OnDone::Success};
} }
@@ -734,7 +734,7 @@ void tst_Tasking::testTree_data()
const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); const Group root5 = createRoot(WorkflowPolicy::StopOnFinished);
QTest::newRow("ErrorStopOnFinished") << TestData{storage, root5, log, 1, OnDone::Failure}; QTest::newRow("ErrorStopOnFinished") << TestData{storage, root5, log, 1, OnDone::Failure};
const Group root6 = createRoot(WorkflowPolicy::Optional); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndDone);
QTest::newRow("ErrorOptional") << TestData{storage, root6, optionalLog, 1, OnDone::Success}; QTest::newRow("ErrorOptional") << TestData{storage, root6, optionalLog, 1, OnDone::Success};
} }
@@ -799,7 +799,7 @@ void tst_Tasking::testTree_data()
QTest::newRow("StopRootWithStopOnFinished") QTest::newRow("StopRootWithStopOnFinished")
<< TestData{storage, root5, errorErrorLog, 2, OnDone::Failure}; << TestData{storage, root5, errorErrorLog, 2, OnDone::Failure};
const Group root6 = createRoot(WorkflowPolicy::Optional); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndDone);
QTest::newRow("StopRootWithOptional") QTest::newRow("StopRootWithOptional")
<< TestData{storage, root6, doneLog, 2, OnDone::Success}; << TestData{storage, root6, doneLog, 2, OnDone::Success};
} }
@@ -883,7 +883,7 @@ void tst_Tasking::testTree_data()
QTest::newRow("StopRootAfterDoneWithStopOnFinished") QTest::newRow("StopRootAfterDoneWithStopOnFinished")
<< TestData{storage, root5, doneErrorLog, 3, OnDone::Success}; << TestData{storage, root5, doneErrorLog, 3, OnDone::Success};
const Group root6 = createRoot(WorkflowPolicy::Optional); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndDone);
QTest::newRow("StopRootAfterDoneWithOptional") QTest::newRow("StopRootAfterDoneWithOptional")
<< TestData{storage, root6, doneDoneLog, 3, OnDone::Success}; << TestData{storage, root6, doneDoneLog, 3, OnDone::Success};
} }
@@ -947,7 +947,7 @@ void tst_Tasking::testTree_data()
QTest::newRow("StopGroupWithStopOnFinished") QTest::newRow("StopGroupWithStopOnFinished")
<< TestData{storage, root5, errorLog, 2, OnDone::Failure}; << TestData{storage, root5, errorLog, 2, OnDone::Failure};
const Group root6 = createRoot(WorkflowPolicy::Optional); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndDone);
QTest::newRow("StopGroupWithOptional") QTest::newRow("StopGroupWithOptional")
<< TestData{storage, root6, doneLog, 2, OnDone::Failure}; << TestData{storage, root6, doneLog, 2, OnDone::Failure};
} }
@@ -1025,7 +1025,7 @@ void tst_Tasking::testTree_data()
QTest::newRow("StopGroupAfterDoneWithStopOnFinished") QTest::newRow("StopGroupAfterDoneWithStopOnFinished")
<< TestData{storage, root5, shortDoneLog, 3, OnDone::Failure}; << TestData{storage, root5, shortDoneLog, 3, OnDone::Failure};
const Group root6 = createRoot(WorkflowPolicy::Optional); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndDone);
QTest::newRow("StopGroupAfterDoneWithOptional") QTest::newRow("StopGroupAfterDoneWithOptional")
<< TestData{storage, root6, longDoneLog, 3, OnDone::Failure}; << TestData{storage, root6, longDoneLog, 3, OnDone::Failure};
} }
@@ -1103,7 +1103,7 @@ void tst_Tasking::testTree_data()
QTest::newRow("StopGroupAfterErrorWithStopOnFinished") QTest::newRow("StopGroupAfterErrorWithStopOnFinished")
<< TestData{storage, root5, shortErrorLog, 3, OnDone::Failure}; << TestData{storage, root5, shortErrorLog, 3, OnDone::Failure};
const Group root6 = createRoot(WorkflowPolicy::Optional); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndDone);
QTest::newRow("StopGroupAfterErrorWithOptional") QTest::newRow("StopGroupAfterErrorWithOptional")
<< TestData{storage, root6, doneLog, 3, OnDone::Failure}; << TestData{storage, root6, doneLog, 3, OnDone::Failure};
} }
@@ -1216,7 +1216,7 @@ void tst_Tasking::testTree_data()
{ {
const Group root { const Group root {
Storage(storage), Storage(storage),
optional, finishAllAndDone,
createFailingTask(1), createFailingTask(1),
createFailingTask(2), createFailingTask(2),
groupDone(0), groupDone(0),

View File

@@ -101,7 +101,7 @@ int main(int argc, char *argv[])
task_4_4->setBusyTime(3); task_4_4->setBusyTime(3);
groupTask_1->setWorkflowPolicy(Tasking::WorkflowPolicy::ContinueOnDone); groupTask_1->setWorkflowPolicy(Tasking::WorkflowPolicy::ContinueOnDone);
groupTask_4->setWorkflowPolicy(Tasking::WorkflowPolicy::Optional); groupTask_4->setWorkflowPolicy(Tasking::WorkflowPolicy::FinishAllAndDone);
groupTask_4_3->setExecuteMode(ExecuteMode::Parallel); groupTask_4_3->setExecuteMode(ExecuteMode::Parallel);
groupTask_4_3->setWorkflowPolicy(Tasking::WorkflowPolicy::StopOnError); groupTask_4_3->setWorkflowPolicy(Tasking::WorkflowPolicy::StopOnError);

View File

@@ -133,7 +133,7 @@ GroupWidget::GroupWidget()
m_workflowCombo->addItem("Cont On Error", (int)Tasking::WorkflowPolicy::ContinueOnError); m_workflowCombo->addItem("Cont On Error", (int)Tasking::WorkflowPolicy::ContinueOnError);
m_workflowCombo->addItem("Stop On Done", (int)Tasking::WorkflowPolicy::StopOnDone); m_workflowCombo->addItem("Stop On Done", (int)Tasking::WorkflowPolicy::StopOnDone);
m_workflowCombo->addItem("Cont On Done", (int)Tasking::WorkflowPolicy::ContinueOnDone); m_workflowCombo->addItem("Cont On Done", (int)Tasking::WorkflowPolicy::ContinueOnDone);
m_workflowCombo->addItem("Optional", (int)Tasking::WorkflowPolicy::Optional); m_workflowCombo->addItem("Optional", (int)Tasking::WorkflowPolicy::FinishAllAndDone);
updateWorkflowPolicy(); updateWorkflowPolicy();
connect(m_workflowCombo, &QComboBox::currentIndexChanged, this, [this](int index) { connect(m_workflowCombo, &QComboBox::currentIndexChanged, this, [this](int index) {
m_workflowPolicy = (Tasking::WorkflowPolicy)m_workflowCombo->itemData(index).toInt(); m_workflowPolicy = (Tasking::WorkflowPolicy)m_workflowCombo->itemData(index).toInt();