summaryrefslogtreecommitdiff
path: root/tests/manual/tasktree
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2023-01-06 16:07:16 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2023-01-06 15:28:19 +0000
commitb6208ab34aa53280f06622edf1e3aa506aed96b6 (patch)
treeace91ca5f95f64e541bb4edcb789a3d7d1d904ae /tests/manual/tasktree
parentfbb8d94e55bccfda87e97d4ad203575bf0ab88a2 (diff)
downloadqt-creator-b6208ab34aa53280f06622edf1e3aa506aed96b6.tar.gz
TaskTree: Introduce ParallelLimit
The parallel limit constrains the number of parallel tasks run in the same time. So, if e.g. a group contains 10 children and the parallel limit is 6, only first 6 tasks are being started on the beginning and the rest 4 are being postponed until some running tasks are finished. So, when the one of 6 running tasks finishes the group starts the 7th task and so on. Setting parallel limit to 1 means sequential invocation in fact. The value of 0 means there is no limit and all tasks are run at once. Remove the ExecuteMode enum, as this is modelled now by the parallelLimit. Change-Id: Ice59318be0915401f05bb5a5804078bdc591d09f Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'tests/manual/tasktree')
-rw-r--r--tests/manual/tasktree/main.cpp10
-rw-r--r--tests/manual/tasktree/taskwidget.cpp12
-rw-r--r--tests/manual/tasktree/taskwidget.h11
3 files changed, 19 insertions, 14 deletions
diff --git a/tests/manual/tasktree/main.cpp b/tests/manual/tasktree/main.cpp
index e0a0048374..b57481bfc4 100644
--- a/tests/manual/tasktree/main.cpp
+++ b/tests/manual/tasktree/main.cpp
@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
groupTask_1->setWorkflowPolicy(Tasking::WorkflowPolicy::ContinueOnDone);
groupTask_4->setWorkflowPolicy(Tasking::WorkflowPolicy::Optional);
- groupTask_4_3->setExecuteMode(Tasking::ExecuteMode::Parallel);
+ groupTask_4_3->setExecuteMode(ExecuteMode::Parallel);
groupTask_4_3->setWorkflowPolicy(Tasking::WorkflowPolicy::StopOnError);
// Task layout
@@ -170,14 +170,14 @@ int main(int argc, char *argv[])
};
const Group root {
- Execute(rootGroup->executeMode()),
+ rootGroup->executeMode(),
Workflow(rootGroup->workflowPolicy()),
OnGroupSetup([rootGroup] { rootGroup->setState(State::Running); }),
OnGroupDone([rootGroup] { rootGroup->setState(State::Done); }),
OnGroupError([rootGroup] { rootGroup->setState(State::Error); }),
Group {
- Execute(groupTask_1->executeMode()),
+ groupTask_1->executeMode(),
Workflow(groupTask_1->workflowPolicy()),
OnGroupSetup([groupTask_1] { groupTask_1->setState(State::Running); }),
OnGroupDone([groupTask_1] { groupTask_1->setState(State::Done); }),
@@ -190,7 +190,7 @@ int main(int argc, char *argv[])
taskItem(task_2),
taskItem(task_3),
Group {
- Execute(groupTask_4->executeMode()),
+ groupTask_4->executeMode(),
Workflow(groupTask_4->workflowPolicy()),
OnGroupSetup([groupTask_4] { groupTask_4->setState(State::Running); }),
OnGroupDone([groupTask_4] { groupTask_4->setState(State::Done); }),
@@ -199,7 +199,7 @@ int main(int argc, char *argv[])
taskItem(task_4_1),
taskItem(task_4_2),
Group {
- Execute(groupTask_4_3->executeMode()),
+ groupTask_4_3->executeMode(),
Workflow(groupTask_4_3->workflowPolicy()),
OnGroupSetup([groupTask_4_3] { groupTask_4_3->setState(State::Running); }),
OnGroupDone([groupTask_4_3] { groupTask_4_3->setState(State::Done); }),
diff --git a/tests/manual/tasktree/taskwidget.cpp b/tests/manual/tasktree/taskwidget.cpp
index a6901f8d13..d4ddc0194a 100644
--- a/tests/manual/tasktree/taskwidget.cpp
+++ b/tests/manual/tasktree/taskwidget.cpp
@@ -121,11 +121,11 @@ GroupWidget::GroupWidget()
{
m_stateIndicator->setFixedWidth(30);
- m_executeCombo->addItem("Sequential", (int)Tasking::ExecuteMode::Sequential);
- m_executeCombo->addItem("Parallel", (int)Tasking::ExecuteMode::Parallel);
+ m_executeCombo->addItem("Sequential", (int)ExecuteMode::Sequential);
+ m_executeCombo->addItem("Parallel", (int)ExecuteMode::Parallel);
updateExecuteMode();
connect(m_executeCombo, &QComboBox::currentIndexChanged, this, [this](int index) {
- m_executeMode = (Tasking::ExecuteMode)m_executeCombo->itemData(index).toInt();
+ m_executeMode = (ExecuteMode)m_executeCombo->itemData(index).toInt();
});
m_workflowCombo->addItem("Stop On Error", (int)Tasking::WorkflowPolicy::StopOnError);
@@ -152,7 +152,7 @@ GroupWidget::GroupWidget()
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
}
-void GroupWidget::setExecuteMode(Tasking::ExecuteMode mode)
+void GroupWidget::setExecuteMode(ExecuteMode mode)
{
m_executeMode = mode;
updateExecuteMode();
@@ -163,9 +163,9 @@ void GroupWidget::updateExecuteMode()
m_executeCombo->setCurrentIndex(m_executeCombo->findData((int)m_executeMode));
}
-Tasking::ExecuteMode GroupWidget::executeMode() const
+Tasking::ParallelLimit GroupWidget::executeMode() const
{
- return m_executeMode;
+ return m_executeMode == ExecuteMode::Sequential ? Tasking::sequential : Tasking::parallel;
}
void GroupWidget::setWorkflowPolicy(Tasking::WorkflowPolicy policy)
diff --git a/tests/manual/tasktree/taskwidget.h b/tests/manual/tasktree/taskwidget.h
index be21ae02e9..7421ca5a30 100644
--- a/tests/manual/tasktree/taskwidget.h
+++ b/tests/manual/tasktree/taskwidget.h
@@ -22,6 +22,11 @@ enum class State {
Error
};
+enum class ExecuteMode {
+ Sequential, // default
+ Parallel
+};
+
class StateWidget : public QWidget
{
public:
@@ -54,8 +59,8 @@ class GroupWidget : public StateWidget
public:
GroupWidget();
- void setExecuteMode(Utils::Tasking::ExecuteMode mode);
- Utils::Tasking::ExecuteMode executeMode() const;
+ void setExecuteMode(ExecuteMode mode);
+ Utils::Tasking::ParallelLimit executeMode() const;
void setWorkflowPolicy(Utils::Tasking::WorkflowPolicy policy);
Utils::Tasking::WorkflowPolicy workflowPolicy() const;
@@ -67,7 +72,7 @@ private:
QComboBox *m_executeCombo = nullptr;
QComboBox *m_workflowCombo = nullptr;
- Utils::Tasking::ExecuteMode m_executeMode = Utils::Tasking::ExecuteMode::Sequential;
+ ExecuteMode m_executeMode = ExecuteMode::Sequential;
Utils::Tasking::WorkflowPolicy m_workflowPolicy = Utils::Tasking::WorkflowPolicy::StopOnError;
};