forked from qt-creator/qt-creator
TaskTree: Derive Sync from GroupItem instead of from Group
Change-Id: I6fd9ce48d3105f95f566ccb3328875872fd4af2b Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -190,7 +190,7 @@ protected:
|
|||||||
static GroupItem parallelLimit(int limit) { return GroupItem({{}, limit}); }
|
static GroupItem parallelLimit(int limit) { return GroupItem({{}, limit}); }
|
||||||
static GroupItem workflowPolicy(WorkflowPolicy policy) { return GroupItem({{}, {}, policy}); }
|
static GroupItem workflowPolicy(WorkflowPolicy policy) { return GroupItem({{}, {}, policy}); }
|
||||||
static GroupItem withTimeout(const GroupItem &item, std::chrono::milliseconds timeout,
|
static GroupItem withTimeout(const GroupItem &item, std::chrono::milliseconds timeout,
|
||||||
const GroupEndHandler &handler = {});
|
const GroupEndHandler &handler = {});
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type m_type = Type::Group;
|
Type m_type = Type::Group;
|
||||||
@@ -274,15 +274,15 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Synchronous invocation. Similarly to Group - isn't counted as a task inside taskCount()
|
// Synchronous invocation. Similarly to Group - isn't counted as a task inside taskCount()
|
||||||
class TASKING_EXPORT Sync final : public Group
|
class TASKING_EXPORT Sync final : public GroupItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template<typename Function>
|
template<typename Function>
|
||||||
Sync(Function &&function) : Group(init(std::forward<Function>(function))) {}
|
Sync(Function &&function) { addChildren({init(std::forward<Function>(function))}); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template<typename Function>
|
template<typename Function>
|
||||||
static QList<GroupItem> init(Function &&function) {
|
static GroupItem init(Function &&function) {
|
||||||
constexpr bool isInvocable = std::is_invocable_v<std::decay_t<Function>>;
|
constexpr bool isInvocable = std::is_invocable_v<std::decay_t<Function>>;
|
||||||
static_assert(isInvocable,
|
static_assert(isInvocable,
|
||||||
"Sync element: The synchronous function can't take any arguments.");
|
"Sync element: The synchronous function can't take any arguments.");
|
||||||
@@ -291,10 +291,10 @@ private:
|
|||||||
static_assert(isBool || isVoid,
|
static_assert(isBool || isVoid,
|
||||||
"Sync element: The synchronous function has to return void or bool.");
|
"Sync element: The synchronous function has to return void or bool.");
|
||||||
if constexpr (isBool) {
|
if constexpr (isBool) {
|
||||||
return {onGroupSetup([function] { return function() ? SetupResult::StopWithDone
|
return onGroupSetup([function] { return function() ? SetupResult::StopWithDone
|
||||||
: SetupResult::StopWithError; })};
|
: SetupResult::StopWithError; });
|
||||||
}
|
}
|
||||||
return {onGroupSetup([function] { function(); return SetupResult::StopWithDone; })};
|
return onGroupSetup([function] { function(); return SetupResult::StopWithDone; });
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user