TaskTree: Rename StopOnFinished into StopOnSuccessOrError

In order to conform to CallDoneIf::SuccessOrError.

Amends 2c0a59384c

Change-Id: I2704667ca8d005c63c13b62786010ce430f0b550
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2023-11-08 13:52:27 +01:00
parent 16233c51cd
commit 79421fd597
3 changed files with 53 additions and 48 deletions

View File

@@ -498,8 +498,8 @@ private:
afterwards, even when some other tasks in the group finished with an error. afterwards, even when some other tasks in the group finished with an error.
If all child tasks finish with an error, the group finishes with an error. If all child tasks finish with an error, the group finishes with an error.
If a group is empty, it finishes with an error. If a group is empty, it finishes with an error.
\value StopOnFinished \value StopOnSuccessOrError
Corresponds to the stopOnFinished global element. Corresponds to the stopOnSuccessOrError global element.
The group starts as many tasks as it can. When any task finishes, The group starts as many tasks as it can. When any task finishes,
the group stops and reports the task's result. the group stops and reports the task's result.
Useful only in parallel mode. Useful only in parallel mode.
@@ -518,7 +518,7 @@ private:
If a group is empty, it finishes with an error. If a group is empty, it finishes with an error.
Whenever a child task's result causes the Group to stop, Whenever a child task's result causes the Group to stop,
i.e. in case of StopOnError, StopOnSuccess, or StopOnFinished policies, i.e. in case of StopOnError, StopOnSuccess, or StopOnSuccessOrError policies,
the Group stops the other running child tasks (if any - for example in parallel mode), the Group stops the other running child tasks (if any - for example in parallel mode),
and skips executing tasks it has not started yet (for example, in the sequential mode - and skips executing tasks it has not started yet (for example, in the sequential mode -
those, that are placed after the failed task). Both stopping and skipping child tasks those, that are placed after the failed task). Both stopping and skipping child tasks
@@ -553,7 +553,7 @@ private:
\li Success when at least one child task succeeded, an error otherwise \li Success when at least one child task succeeded, an error otherwise
\li An error \li An error
\row \row
\li StopOnFinished \li StopOnSuccessOrError
\li Stops when any child task finished and reports child task's result \li Stops when any child task finished and reports child task's result
\li Success or an error, depending on the finished child task's result \li Success or an error, depending on the finished child task's result
\li An error \li An error
@@ -571,8 +571,9 @@ private:
If a child of a group is also a group, the child group runs its tasks according to its own If a child of a group is also a group, the child group runs its tasks according to its own
workflow policy. When a parent group stops the running child group because workflow policy. When a parent group stops the running child group because
of parent group's workflow policy, i.e. when the StopOnError, StopOnSuccess, or StopOnFinished of parent group's workflow policy, i.e. when the StopOnError, StopOnSuccess,
policy was used for the parent, the child group's result is reported according to the or StopOnSuccessOrError policy was used for the parent,
the child group's result is reported according to the
\b Result column and to the \b {child group's workflow policy} row in the table above. \b Result column and to the \b {child group's workflow policy} row in the table above.
*/ */
@@ -625,8 +626,8 @@ private:
*/ */
/*! /*!
\variable stopOnFinished \variable stopOnSuccessOrError
A convenient global group's element describing the StopOnFinished workflow policy. A convenient global group's element describing the StopOnSuccessOrError workflow policy.
*/ */
/*! /*!
@@ -815,7 +816,7 @@ GroupItem parallelLimit(int limit)
For convenience, global elements may be used instead. For convenience, global elements may be used instead.
\sa stopOnError, continueOnError, stopOnSuccess, continueOnSuccess, stopOnFinished, \sa stopOnError, continueOnError, stopOnSuccess, continueOnSuccess, stopOnSuccessOrError,
finishAllAndSuccess, finishAllAndError, WorkflowPolicy finishAllAndSuccess, finishAllAndError, WorkflowPolicy
*/ */
GroupItem workflowPolicy(WorkflowPolicy policy) GroupItem workflowPolicy(WorkflowPolicy policy)
@@ -830,7 +831,7 @@ const GroupItem stopOnError = workflowPolicy(WorkflowPolicy::StopOnError);
const GroupItem continueOnError = workflowPolicy(WorkflowPolicy::ContinueOnError); const GroupItem continueOnError = workflowPolicy(WorkflowPolicy::ContinueOnError);
const GroupItem stopOnSuccess = workflowPolicy(WorkflowPolicy::StopOnSuccess); const GroupItem stopOnSuccess = workflowPolicy(WorkflowPolicy::StopOnSuccess);
const GroupItem continueOnSuccess = workflowPolicy(WorkflowPolicy::ContinueOnSuccess); const GroupItem continueOnSuccess = workflowPolicy(WorkflowPolicy::ContinueOnSuccess);
const GroupItem stopOnFinished = workflowPolicy(WorkflowPolicy::StopOnFinished); const GroupItem stopOnSuccessOrError = workflowPolicy(WorkflowPolicy::StopOnSuccessOrError);
const GroupItem finishAllAndSuccess = workflowPolicy(WorkflowPolicy::FinishAllAndSuccess); const GroupItem finishAllAndSuccess = workflowPolicy(WorkflowPolicy::FinishAllAndSuccess);
const GroupItem finishAllAndError = workflowPolicy(WorkflowPolicy::FinishAllAndError); const GroupItem finishAllAndError = workflowPolicy(WorkflowPolicy::FinishAllAndError);
@@ -1040,7 +1041,7 @@ GroupItem GroupItem::withTimeout(const GroupItem &item, milliseconds timeout,
const auto onSetup = [timeout](milliseconds &timeoutData) { timeoutData = timeout; }; const auto onSetup = [timeout](milliseconds &timeoutData) { timeoutData = timeout; };
return Group { return Group {
parallel, parallel,
stopOnFinished, stopOnSuccessOrError,
Group { Group {
finishAllAndError, finishAllAndError,
handler ? TimeoutTask(onSetup, [handler] { handler(); }, CallDoneIf::Success) handler ? TimeoutTask(onSetup, [handler] { handler(); }, CallDoneIf::Success)
@@ -1321,7 +1322,7 @@ static bool initialSuccessBit(WorkflowPolicy workflowPolicy)
return true; return true;
case WorkflowPolicy::StopOnSuccess: case WorkflowPolicy::StopOnSuccess:
case WorkflowPolicy::ContinueOnSuccess: case WorkflowPolicy::ContinueOnSuccess:
case WorkflowPolicy::StopOnFinished: case WorkflowPolicy::StopOnSuccessOrError:
case WorkflowPolicy::FinishAllAndError: case WorkflowPolicy::FinishAllAndError:
return false; return false;
} }
@@ -1350,8 +1351,8 @@ bool TaskContainer::RuntimeData::updateSuccessBit(bool success)
{ {
if (m_constData.m_workflowPolicy == WorkflowPolicy::FinishAllAndSuccess if (m_constData.m_workflowPolicy == WorkflowPolicy::FinishAllAndSuccess
|| m_constData.m_workflowPolicy == WorkflowPolicy::FinishAllAndError || m_constData.m_workflowPolicy == WorkflowPolicy::FinishAllAndError
|| m_constData.m_workflowPolicy == WorkflowPolicy::StopOnFinished) { || m_constData.m_workflowPolicy == WorkflowPolicy::StopOnSuccessOrError) {
if (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnFinished) if (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnSuccessOrError)
m_successBit = success; m_successBit = success;
return m_successBit; return m_successBit;
} }
@@ -1440,7 +1441,7 @@ SetupResult TaskContainer::childDone(bool success)
{ {
QT_CHECK(isRunning()); QT_CHECK(isRunning());
const int limit = m_runtimeData->currentLimit(); // Read before bumping m_doneCount and stop() const int limit = m_runtimeData->currentLimit(); // Read before bumping m_doneCount and stop()
const bool shouldStop = m_constData.m_workflowPolicy == WorkflowPolicy::StopOnFinished const bool shouldStop = m_constData.m_workflowPolicy == WorkflowPolicy::StopOnSuccessOrError
|| (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnSuccess && success) || (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnSuccess && success)
|| (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnError && !success); || (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnError && !success);
if (shouldStop) if (shouldStop)

View File

@@ -103,13 +103,13 @@ private:
enum class WorkflowPolicy enum class WorkflowPolicy
{ {
StopOnError, // 1a - Reports error on first child error, otherwise success (if all children were success). StopOnError, // 1a - Reports error on first child error, otherwise success (if all children were success).
ContinueOnError, // 1b - The same, but children execution continues. Reports success when no children. ContinueOnError, // 1b - The same, but children execution continues. Reports success when no children.
StopOnSuccess, // 2a - Reports success on first child success, otherwise error (if all children were error). StopOnSuccess, // 2a - Reports success on first child success, otherwise error (if all children were error).
ContinueOnSuccess, // 2b - The same, but children execution continues. Reports error when no children. ContinueOnSuccess, // 2b - The same, but children execution continues. Reports error when no children.
StopOnFinished, // 3 - Stops on first finished child and report its result. StopOnSuccessOrError, // 3 - Stops on first finished child and report its result.
FinishAllAndSuccess, // 4 - Reports success after all children finished. FinishAllAndSuccess, // 4 - Reports success after all children finished.
FinishAllAndError // 5 - Reports error after all children finished. FinishAllAndError // 5 - Reports error after all children finished.
}; };
Q_ENUM_NS(WorkflowPolicy); Q_ENUM_NS(WorkflowPolicy);
@@ -321,7 +321,7 @@ TASKING_EXPORT extern const GroupItem stopOnError;
TASKING_EXPORT extern const GroupItem continueOnError; TASKING_EXPORT extern const GroupItem continueOnError;
TASKING_EXPORT extern const GroupItem stopOnSuccess; TASKING_EXPORT extern const GroupItem stopOnSuccess;
TASKING_EXPORT extern const GroupItem continueOnSuccess; TASKING_EXPORT extern const GroupItem continueOnSuccess;
TASKING_EXPORT extern const GroupItem stopOnFinished; TASKING_EXPORT extern const GroupItem stopOnSuccessOrError;
TASKING_EXPORT extern const GroupItem finishAllAndSuccess; TASKING_EXPORT extern const GroupItem finishAllAndSuccess;
TASKING_EXPORT extern const GroupItem finishAllAndError; TASKING_EXPORT extern const GroupItem finishAllAndError;

View File

@@ -614,7 +614,7 @@ void tst_Tasking::testTree_data()
QTest::newRow("DoneAndContinueOnError") << doneData(WorkflowPolicy::ContinueOnError); QTest::newRow("DoneAndContinueOnError") << doneData(WorkflowPolicy::ContinueOnError);
QTest::newRow("DoneAndStopOnSuccess") << doneData(WorkflowPolicy::StopOnSuccess); QTest::newRow("DoneAndStopOnSuccess") << doneData(WorkflowPolicy::StopOnSuccess);
QTest::newRow("DoneAndContinueOnSuccess") << doneData(WorkflowPolicy::ContinueOnSuccess); QTest::newRow("DoneAndContinueOnSuccess") << doneData(WorkflowPolicy::ContinueOnSuccess);
QTest::newRow("DoneAndStopOnFinished") << doneData(WorkflowPolicy::StopOnFinished); QTest::newRow("DoneAndStopOnSuccessOrError") << doneData(WorkflowPolicy::StopOnSuccessOrError);
QTest::newRow("DoneAndFinishAllAndSuccess") << doneData(WorkflowPolicy::FinishAllAndSuccess); QTest::newRow("DoneAndFinishAllAndSuccess") << doneData(WorkflowPolicy::FinishAllAndSuccess);
QTest::newRow("DoneAndFinishAllAndError") << doneData(WorkflowPolicy::FinishAllAndError); QTest::newRow("DoneAndFinishAllAndError") << doneData(WorkflowPolicy::FinishAllAndError);
@@ -622,7 +622,7 @@ void tst_Tasking::testTree_data()
QTest::newRow("ErrorAndContinueOnError") << errorData(WorkflowPolicy::ContinueOnError); QTest::newRow("ErrorAndContinueOnError") << errorData(WorkflowPolicy::ContinueOnError);
QTest::newRow("ErrorAndStopOnSuccess") << errorData(WorkflowPolicy::StopOnSuccess); QTest::newRow("ErrorAndStopOnSuccess") << errorData(WorkflowPolicy::StopOnSuccess);
QTest::newRow("ErrorAndContinueOnSuccess") << errorData(WorkflowPolicy::ContinueOnSuccess); QTest::newRow("ErrorAndContinueOnSuccess") << errorData(WorkflowPolicy::ContinueOnSuccess);
QTest::newRow("ErrorAndStopOnFinished") << errorData(WorkflowPolicy::StopOnFinished); QTest::newRow("ErrorAndStopOnSuccessOrError") << errorData(WorkflowPolicy::StopOnSuccessOrError);
QTest::newRow("ErrorAndFinishAllAndSuccess") << errorData(WorkflowPolicy::FinishAllAndSuccess); QTest::newRow("ErrorAndFinishAllAndSuccess") << errorData(WorkflowPolicy::FinishAllAndSuccess);
QTest::newRow("ErrorAndFinishAllAndError") << errorData(WorkflowPolicy::FinishAllAndError); QTest::newRow("ErrorAndFinishAllAndError") << errorData(WorkflowPolicy::FinishAllAndError);
} }
@@ -974,8 +974,8 @@ void tst_Tasking::testTree_data()
QTest::newRow("EmptyContinueOnSuccess") << TestData{storage, root4, errorLog, 0, QTest::newRow("EmptyContinueOnSuccess") << TestData{storage, root4, errorLog, 0,
DoneWith::Error}; DoneWith::Error};
const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError);
QTest::newRow("EmptyStopOnFinished") << TestData{storage, root5, errorLog, 0, QTest::newRow("EmptyStopOnSuccessOrError") << TestData{storage, root5, errorLog, 0,
DoneWith::Error}; DoneWith::Error};
const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess);
@@ -1026,8 +1026,8 @@ void tst_Tasking::testTree_data()
QTest::newRow("DoneContinueOnSuccess") << TestData{storage, root4, doneLog, 1, QTest::newRow("DoneContinueOnSuccess") << TestData{storage, root4, doneLog, 1,
DoneWith::Success}; DoneWith::Success};
const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError);
QTest::newRow("DoneStopOnFinished") << TestData{storage, root5, doneLog, 1, QTest::newRow("DoneStopOnSuccessOrError") << TestData{storage, root5, doneLog, 1,
DoneWith::Success}; DoneWith::Success};
const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess);
@@ -1078,8 +1078,8 @@ void tst_Tasking::testTree_data()
QTest::newRow("ErrorContinueOnSuccess") << TestData{storage, root4, errorLog, 1, QTest::newRow("ErrorContinueOnSuccess") << TestData{storage, root4, errorLog, 1,
DoneWith::Error}; DoneWith::Error};
const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError);
QTest::newRow("ErrorStopOnFinished") << TestData{storage, root5, errorLog, 1, QTest::newRow("ErrorStopOnSuccessOrError") << TestData{storage, root5, errorLog, 1,
DoneWith::Error}; DoneWith::Error};
const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess);
@@ -1147,8 +1147,8 @@ void tst_Tasking::testTree_data()
QTest::newRow("StopRootWithContinueOnSuccess") QTest::newRow("StopRootWithContinueOnSuccess")
<< TestData{storage, root4, doneLog, 2, DoneWith::Success}; << TestData{storage, root4, doneLog, 2, DoneWith::Success};
const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError);
QTest::newRow("StopRootWithStopOnFinished") QTest::newRow("StopRootWithStopOnSuccessOrError")
<< TestData{storage, root5, errorErrorLog, 2, DoneWith::Error}; << TestData{storage, root5, errorErrorLog, 2, DoneWith::Error};
const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess);
@@ -1234,8 +1234,8 @@ void tst_Tasking::testTree_data()
QTest::newRow("StopRootAfterDoneWithContinueOnSuccess") QTest::newRow("StopRootAfterDoneWithContinueOnSuccess")
<< TestData{storage, root4, doneDoneLog, 3, DoneWith::Success}; << TestData{storage, root4, doneDoneLog, 3, DoneWith::Success};
const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError);
QTest::newRow("StopRootAfterDoneWithStopOnFinished") QTest::newRow("StopRootAfterDoneWithStopOnSuccessOrError")
<< TestData{storage, root5, doneErrorLog, 3, DoneWith::Success}; << TestData{storage, root5, doneErrorLog, 3, DoneWith::Success};
const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess);
@@ -1291,8 +1291,8 @@ void tst_Tasking::testTree_data()
QTest::newRow("StopGroupWithContinueOnSuccess") QTest::newRow("StopGroupWithContinueOnSuccess")
<< TestData{storage, root4, log, 2, DoneWith::Error}; << TestData{storage, root4, log, 2, DoneWith::Error};
const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError);
QTest::newRow("StopGroupWithStopOnFinished") QTest::newRow("StopGroupWithStopOnSuccessOrError")
<< TestData{storage, root5, log, 2, DoneWith::Error}; << TestData{storage, root5, log, 2, DoneWith::Error};
// TODO: Behavioral change! Fix Docs! // TODO: Behavioral change! Fix Docs!
@@ -1363,8 +1363,8 @@ void tst_Tasking::testTree_data()
QTest::newRow("StopGroupAfterDoneWithContinueOnSuccess") QTest::newRow("StopGroupAfterDoneWithContinueOnSuccess")
<< TestData{storage, root4, errorLog, 3, DoneWith::Error}; << TestData{storage, root4, errorLog, 3, DoneWith::Error};
const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError);
QTest::newRow("StopGroupAfterDoneWithStopOnFinished") QTest::newRow("StopGroupAfterDoneWithStopOnSuccessOrError")
<< TestData{storage, root5, doneLog, 3, DoneWith::Error}; << TestData{storage, root5, doneLog, 3, DoneWith::Error};
// TODO: Behavioral change! // TODO: Behavioral change!
@@ -1433,8 +1433,8 @@ void tst_Tasking::testTree_data()
QTest::newRow("StopGroupAfterErrorWithContinueOnSuccess") QTest::newRow("StopGroupAfterErrorWithContinueOnSuccess")
<< TestData{storage, root4, longLog, 3, DoneWith::Error}; << TestData{storage, root4, longLog, 3, DoneWith::Error};
const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError);
QTest::newRow("StopGroupAfterErrorWithStopOnFinished") QTest::newRow("StopGroupAfterErrorWithStopOnSuccessOrError")
<< TestData{storage, root5, shortLog, 3, DoneWith::Error}; << TestData{storage, root5, shortLog, 3, DoneWith::Error};
// TODO: Behavioral change! // TODO: Behavioral change!
@@ -1502,13 +1502,13 @@ void tst_Tasking::testTree_data()
}; };
QTest::newRow("ContinueOnSuccess") << TestData{storage, root4, doneLog, 3, DoneWith::Success}; QTest::newRow("ContinueOnSuccess") << TestData{storage, root4, doneLog, 3, DoneWith::Success};
const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError);
const Log log5 { const Log log5 {
{1, Handler::Setup}, {1, Handler::Setup},
{1, Handler::Success}, {1, Handler::Success},
{0, Handler::GroupSuccess} {0, Handler::GroupSuccess}
}; };
QTest::newRow("StopOnFinished") << TestData{storage, root5, log5, 3, DoneWith::Success}; QTest::newRow("StopOnSuccessOrError") << TestData{storage, root5, log5, 3, DoneWith::Success};
const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess); const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess);
QTest::newRow("FinishAllAndSuccess") << TestData{storage, root6, doneLog, 3, DoneWith::Success}; QTest::newRow("FinishAllAndSuccess") << TestData{storage, root6, doneLog, 3, DoneWith::Success};
@@ -1522,7 +1522,7 @@ void tst_Tasking::testTree_data()
DoneResult secondResult) { DoneResult secondResult) {
return Group { return Group {
parallel, parallel,
stopOnFinished, stopOnSuccessOrError,
Storage(storage), Storage(storage),
createTask(1, firstResult, 1000ms), createTask(1, firstResult, 1000ms),
createTask(2, secondResult, 1ms), createTask(2, secondResult, 1ms),
@@ -1550,10 +1550,14 @@ void tst_Tasking::testTree_data()
{0, Handler::GroupError} {0, Handler::GroupError}
}; };
QTest::newRow("StopOnFinished1") << TestData{storage, root1, success, 2, DoneWith::Success}; QTest::newRow("StopOnSuccessOrError1")
QTest::newRow("StopOnFinished2") << TestData{storage, root2, failure, 2, DoneWith::Error}; << TestData{storage, root1, success, 2, DoneWith::Success};
QTest::newRow("StopOnFinished3") << TestData{storage, root3, success, 2, DoneWith::Success}; QTest::newRow("StopOnSuccessOrError2")
QTest::newRow("StopOnFinished4") << TestData{storage, root4, failure, 2, DoneWith::Error}; << TestData{storage, root2, failure, 2, DoneWith::Error};
QTest::newRow("StopOnSuccessOrError3")
<< TestData{storage, root3, success, 2, DoneWith::Success};
QTest::newRow("StopOnSuccessOrError4")
<< TestData{storage, root4, failure, 2, DoneWith::Error};
} }
{ {