TaskTree: Get rid of OnGroup... elements

Change-Id: Id1b600999d2051eff8d2207db8235ad08eb6e663
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2023-05-17 20:03:57 +02:00
parent 0793b945f3
commit 56fda87389
2 changed files with 12 additions and 50 deletions

View File

@@ -990,14 +990,14 @@ void TaskNode::invokeEndHandler(bool success)
qDebug() << "Entering the group";
};
const Group root {
OnGroupSetup(onSetup),
onGroupSetup(onSetup),
ProcessTask(...)
};
\endcode
The group setup handler is optional. To define a group setup handler, add an
OnGroupSetup element to a group. The argument of OnGroupSetup is a user
handler. If you add more than one OnGroupSetup element to a group, an assert
onGroupSetup element to a group. The argument of onGroupSetup is a user
handler. If you add more than one onGroupSetup element to a group, an assert
is triggered at runtime that includes an error message.
Like the task start handler, the group start handler may return TaskAction.
@@ -1011,17 +1011,17 @@ void TaskNode::invokeEndHandler(bool success)
\code
const Group root {
OnGroupSetup([] { qDebug() << "Root setup"; }),
onGroupSetup([] { qDebug() << "Root setup"; }),
Group {
OnGroupSetup([] { qDebug() << "Group 1 setup"; return TaskAction::Continue; }),
onGroupSetup([] { qDebug() << "Group 1 setup"; return TaskAction::Continue; }),
ProcessTask(...) // Process 1
},
Group {
OnGroupSetup([] { qDebug() << "Group 2 setup"; return TaskAction::StopWithDone; }),
onGroupSetup([] { qDebug() << "Group 2 setup"; return TaskAction::StopWithDone; }),
ProcessTask(...) // Process 2
},
Group {
OnGroupSetup([] { qDebug() << "Group 3 setup"; return TaskAction::StopWithError; }),
onGroupSetup([] { qDebug() << "Group 3 setup"; return TaskAction::StopWithError; }),
ProcessTask(...) // Process 3
},
ProcessTask(...) // Process 4
@@ -1080,20 +1080,20 @@ void TaskNode::invokeEndHandler(bool success)
execution of its tasks, respectively. The final value reported by the
group depends on its \l {Workflow Policy}. The handlers can apply other
necessary actions. The done and error handlers are defined inside the
OnGroupDone and OnGroupError elements of a group, respectively. They do not
onGroupDone and onGroupError elements of a group, respectively. They do not
take arguments:
\code
const Group root {
OnGroupSetup([] { qDebug() << "Root setup"; }),
onGroupSetup([] { qDebug() << "Root setup"; }),
ProcessTask(...),
OnGroupDone([] { qDebug() << "Root finished with success"; }),
OnGroupError([] { qDebug() << "Root finished with error"; })
onGroupDone([] { qDebug() << "Root finished with success"; }),
onGroupError([] { qDebug() << "Root finished with error"; })
};
\endcode
The group done and error handlers are optional. If you add more than one
OnGroupDone or OnGroupError each to a group, an assert is triggered at
onGroupDone or onGroupError each to a group, an assert is triggered at
runtime that includes an error message.
\note Even if the group setup handler returns StopWithDone or StopWithError,

View File

@@ -259,44 +259,6 @@ public:
Workflow(WorkflowPolicy policy) : TaskItem(policy) {}
};
class TASKING_EXPORT OnGroupSetup : public TaskItem
{
public:
template <typename SetupFunction>
OnGroupSetup(SetupFunction &&function)
: TaskItem({wrapSetup(std::forward<SetupFunction>(function))}) {}
private:
template<typename SetupFunction>
static TaskItem::GroupSetupHandler wrapSetup(SetupFunction &&function) {
static constexpr bool isDynamic = std::is_same_v<TaskAction,
std::invoke_result_t<std::decay_t<SetupFunction>>>;
constexpr bool isVoid = std::is_same_v<void,
std::invoke_result_t<std::decay_t<SetupFunction>>>;
static_assert(isDynamic || isVoid,
"Group setup handler needs to take no arguments and has to return "
"void or TaskAction. The passed handler doesn't fulfill these requirements.");
return [=] {
if constexpr (isDynamic)
return std::invoke(function);
std::invoke(function);
return TaskAction::Continue;
};
};
};
class TASKING_EXPORT OnGroupDone : public TaskItem
{
public:
OnGroupDone(const GroupEndHandler &handler) : TaskItem({{}, handler}) {}
};
class TASKING_EXPORT OnGroupError : public TaskItem
{
public:
OnGroupError(const GroupEndHandler &handler) : TaskItem({{}, {}, handler}) {}
};
// Synchronous invocation. Similarly to Group - isn't counted as a task inside taskCount()
class TASKING_EXPORT Sync : public Group
{