TaskTree: Introduce WorkflowPolicy::StopOnFinished

The policy is useful mainly in parallel mode.
It stops executing the Group when any task finishes.
It reports the task's result.

Change-Id: I7aa98365cdc4c1eb869ab419d42d0cc5438d43bf
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2023-05-17 19:28:57 +02:00
parent 7bfc3197aa
commit 7501d7587f
3 changed files with 115 additions and 47 deletions

View File

@@ -93,19 +93,22 @@ private:
// WorkflowPolicy:
// 1. When all children finished with done -> report done, otherwise:
// a) Report error on first error and stop executing other children (including their subtree)
// b) On first error - continue executing all children and report error afterwards
// a) Report error on first error and stop executing other children (including their subtree).
// b) On first error - continue executing all children and report error afterwards.
// 2. When all children finished with error -> report error, otherwise:
// a) Report done on first done and stop executing other children (including their subtree)
// b) On first done - continue executing all children and report done afterwards
// 3. Always run all children, ignore their result and report done afterwards
// a) Report done on first done and stop executing other children (including their subtree).
// 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.
// Useful only in parallel mode.
// 4. Always run all children, ignore their result and report done afterwards.
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. When no children it reports done.
StopOnDone, // 2a - Reports done on first child done, otherwise error (if all children were error)
ContinueOnDone, // 2b - The same, but children execution continues. When no children it reports done. (?)
Optional // 3 - Always reports done after all children finished
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).
ContinueOnDone, // 2b - The same, but children execution continues. Reports error when no children.
StopOnFinished, // 3 - Stops on first finished child and report its result.
Optional // 4 - Reports done after all children finished.
};
enum class TaskAction
@@ -287,6 +290,7 @@ TASKING_EXPORT extern Workflow stopOnError;
TASKING_EXPORT extern Workflow continueOnError;
TASKING_EXPORT extern Workflow stopOnDone;
TASKING_EXPORT extern Workflow continueOnDone;
TASKING_EXPORT extern Workflow stopOnFinished;
TASKING_EXPORT extern Workflow optional;
template <typename Task>