From 56fda87389fbc277ca3c3636660209dfc5da82ed Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 17 May 2023 20:03:57 +0200 Subject: [PATCH] TaskTree: Get rid of OnGroup... elements Change-Id: Id1b600999d2051eff8d2207db8235ad08eb6e663 Reviewed-by: Reviewed-by: Qt CI Bot Reviewed-by: hjk --- src/libs/solutions/tasking/tasktree.cpp | 24 ++++++++-------- src/libs/solutions/tasking/tasktree.h | 38 ------------------------- 2 files changed, 12 insertions(+), 50 deletions(-) diff --git a/src/libs/solutions/tasking/tasktree.cpp b/src/libs/solutions/tasking/tasktree.cpp index 06a3804f9dd..57429b90516 100644 --- a/src/libs/solutions/tasking/tasktree.cpp +++ b/src/libs/solutions/tasking/tasktree.cpp @@ -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, diff --git a/src/libs/solutions/tasking/tasktree.h b/src/libs/solutions/tasking/tasktree.h index 08391d9d633..7b37c36eb90 100644 --- a/src/libs/solutions/tasking/tasktree.h +++ b/src/libs/solutions/tasking/tasktree.h @@ -259,44 +259,6 @@ public: Workflow(WorkflowPolicy policy) : TaskItem(policy) {} }; -class TASKING_EXPORT OnGroupSetup : public TaskItem -{ -public: - template - OnGroupSetup(SetupFunction &&function) - : TaskItem({wrapSetup(std::forward(function))}) {} - -private: - template - static TaskItem::GroupSetupHandler wrapSetup(SetupFunction &&function) { - static constexpr bool isDynamic = std::is_same_v>>; - constexpr bool isVoid = std::is_same_v>>; - 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 {