forked from qt-creator/qt-creator
TaskTree: Rename TaskItem into GroupItem
Not all classes derived from TaskItem are tasks, but the common denominator is that all may be placed inside a group: thus GroupItem sounds more appropriate. Addresses the 10th point in the bugreport below. Task-number: QTCREATORBUG-28741 Change-Id: I94d728a8e39ec732810f2e5bbe6b9a76f3bc387c Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> 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:
@@ -43,11 +43,11 @@ private:
|
||||
};
|
||||
|
||||
/*!
|
||||
\class Tasking::TaskItem
|
||||
\class Tasking::GroupItem
|
||||
\inheaderfile solutions/tasking/tasktree.h
|
||||
\inmodule QtCreator
|
||||
\ingroup mainclasses
|
||||
\brief The TaskItem class represents the basic element for composing nested tree structures.
|
||||
\brief The GroupItem class represents the basic element for composing nested tree structures.
|
||||
*/
|
||||
|
||||
/*!
|
||||
@@ -246,7 +246,7 @@ private:
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typealias TaskItem::GroupSetupHandler
|
||||
\typealias GroupItem::GroupSetupHandler
|
||||
|
||||
Type alias for \c std::function<TaskAction()>.
|
||||
|
||||
@@ -277,7 +277,7 @@ private:
|
||||
*/
|
||||
|
||||
/*!
|
||||
\typealias TaskItem::GroupEndHandler
|
||||
\typealias GroupItem::GroupEndHandler
|
||||
|
||||
Type alias for \c std::function\<void()\>.
|
||||
|
||||
@@ -290,13 +290,14 @@ private:
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn template <typename SetupHandler> TaskItem onGroupSetup(SetupHandler &&handler)
|
||||
\fn template <typename SetupHandler> GroupItem onGroupSetup(SetupHandler &&handler)
|
||||
|
||||
Constructs a group's element holding the group setup handler.
|
||||
The \a handler is invoked whenever the group starts.
|
||||
|
||||
The passed \a handler is either of \c std::function<TaskAction()> or \c std::function<void()>
|
||||
type. For more information on possible argument type, refer to \l {TaskItem::GroupSetupHandler}.
|
||||
type. For more information on possible argument type, refer to
|
||||
\l {GroupItem::GroupSetupHandler}.
|
||||
|
||||
When the \a handler is invoked, none of the group's child tasks are running yet.
|
||||
|
||||
@@ -304,7 +305,7 @@ private:
|
||||
after the storages are constructed, so that the \a handler may already
|
||||
perform some initial modifications to the active storages.
|
||||
|
||||
\sa TaskItem::GroupSetupHandler, onGroupDone, onGroupError
|
||||
\sa GroupItem::GroupSetupHandler, onGroupDone, onGroupError
|
||||
*/
|
||||
|
||||
/*!
|
||||
@@ -319,9 +320,9 @@ private:
|
||||
before the storages are destructed, so that the \a handler may still
|
||||
perform a last read of the active storages' data.
|
||||
|
||||
\sa TaskItem::GroupEndHandler, onGroupSetup, onGroupError
|
||||
\sa GroupItem::GroupEndHandler, onGroupSetup, onGroupError
|
||||
*/
|
||||
TaskItem onGroupDone(const TaskItem::GroupEndHandler &handler)
|
||||
GroupItem onGroupDone(const GroupItem::GroupEndHandler &handler)
|
||||
{
|
||||
return Group::onGroupDone(handler);
|
||||
}
|
||||
@@ -338,9 +339,9 @@ TaskItem onGroupDone(const TaskItem::GroupEndHandler &handler)
|
||||
before the storages are destructed, so that the \a handler may still
|
||||
perform a last read of the active storages' data.
|
||||
|
||||
\sa TaskItem::GroupEndHandler, onGroupSetup, onGroupDone
|
||||
\sa GroupItem::GroupEndHandler, onGroupSetup, onGroupDone
|
||||
*/
|
||||
TaskItem onGroupError(const TaskItem::GroupEndHandler &handler)
|
||||
GroupItem onGroupError(const GroupItem::GroupEndHandler &handler)
|
||||
{
|
||||
return Group::onGroupError(handler);
|
||||
}
|
||||
@@ -386,7 +387,7 @@ TaskItem onGroupError(const TaskItem::GroupEndHandler &handler)
|
||||
|
||||
\sa sequential, parallel
|
||||
*/
|
||||
TaskItem parallelLimit(int limit)
|
||||
GroupItem parallelLimit(int limit)
|
||||
{
|
||||
return Group::parallelLimit(qMax(limit, 0));
|
||||
}
|
||||
@@ -399,21 +400,21 @@ TaskItem parallelLimit(int limit)
|
||||
\sa stopOnError, continueOnError, stopOnDone, continueOnDone, stopOnFinished, finishAllAndDone,
|
||||
finishAllAndError, WorkflowPolicy
|
||||
*/
|
||||
TaskItem workflowPolicy(WorkflowPolicy policy)
|
||||
GroupItem workflowPolicy(WorkflowPolicy policy)
|
||||
{
|
||||
return Group::workflowPolicy(policy);
|
||||
}
|
||||
|
||||
const TaskItem sequential = parallelLimit(1);
|
||||
const TaskItem parallel = parallelLimit(0);
|
||||
const GroupItem sequential = parallelLimit(1);
|
||||
const GroupItem parallel = parallelLimit(0);
|
||||
|
||||
const TaskItem stopOnError = workflowPolicy(WorkflowPolicy::StopOnError);
|
||||
const TaskItem continueOnError = workflowPolicy(WorkflowPolicy::ContinueOnError);
|
||||
const TaskItem stopOnDone = workflowPolicy(WorkflowPolicy::StopOnDone);
|
||||
const TaskItem continueOnDone = workflowPolicy(WorkflowPolicy::ContinueOnDone);
|
||||
const TaskItem stopOnFinished = workflowPolicy(WorkflowPolicy::StopOnFinished);
|
||||
const TaskItem finishAllAndDone = workflowPolicy(WorkflowPolicy::FinishAllAndDone);
|
||||
const TaskItem finishAllAndError = workflowPolicy(WorkflowPolicy::FinishAllAndError);
|
||||
const GroupItem stopOnError = workflowPolicy(WorkflowPolicy::StopOnError);
|
||||
const GroupItem continueOnError = workflowPolicy(WorkflowPolicy::ContinueOnError);
|
||||
const GroupItem stopOnDone = workflowPolicy(WorkflowPolicy::StopOnDone);
|
||||
const GroupItem continueOnDone = workflowPolicy(WorkflowPolicy::ContinueOnDone);
|
||||
const GroupItem stopOnFinished = workflowPolicy(WorkflowPolicy::StopOnFinished);
|
||||
const GroupItem finishAllAndDone = workflowPolicy(WorkflowPolicy::FinishAllAndDone);
|
||||
const GroupItem finishAllAndError = workflowPolicy(WorkflowPolicy::FinishAllAndError);
|
||||
|
||||
static TaskAction toTaskAction(bool success)
|
||||
{
|
||||
@@ -483,11 +484,11 @@ void TreeStorageBase::activateStorage(int id) const
|
||||
m_storageData->m_activeStorage = id;
|
||||
}
|
||||
|
||||
void TaskItem::addChildren(const QList<TaskItem> &children)
|
||||
void GroupItem::addChildren(const QList<GroupItem> &children)
|
||||
{
|
||||
QTC_ASSERT(m_type == Type::Group, qWarning("Only Group may have children, skipping...");
|
||||
return);
|
||||
for (const TaskItem &child : children) {
|
||||
for (const GroupItem &child : children) {
|
||||
switch (child.m_type) {
|
||||
case Type::Group:
|
||||
m_children.append(child);
|
||||
@@ -534,7 +535,7 @@ void TaskItem::addChildren(const QList<TaskItem> &children)
|
||||
}
|
||||
}
|
||||
|
||||
void TaskItem::setTaskSetupHandler(const TaskSetupHandler &handler)
|
||||
void GroupItem::setTaskSetupHandler(const TaskSetupHandler &handler)
|
||||
{
|
||||
if (!handler) {
|
||||
qWarning("Setting empty Setup Handler is no-op, skipping...");
|
||||
@@ -545,7 +546,7 @@ void TaskItem::setTaskSetupHandler(const TaskSetupHandler &handler)
|
||||
m_taskHandler.m_setupHandler = handler;
|
||||
}
|
||||
|
||||
void TaskItem::setTaskDoneHandler(const TaskEndHandler &handler)
|
||||
void GroupItem::setTaskDoneHandler(const TaskEndHandler &handler)
|
||||
{
|
||||
if (!handler) {
|
||||
qWarning("Setting empty Done Handler is no-op, skipping...");
|
||||
@@ -556,7 +557,7 @@ void TaskItem::setTaskDoneHandler(const TaskEndHandler &handler)
|
||||
m_taskHandler.m_doneHandler = handler;
|
||||
}
|
||||
|
||||
void TaskItem::setTaskErrorHandler(const TaskEndHandler &handler)
|
||||
void GroupItem::setTaskErrorHandler(const TaskEndHandler &handler)
|
||||
{
|
||||
if (!handler) {
|
||||
qWarning("Setting empty Error Handler is no-op, skipping...");
|
||||
@@ -567,8 +568,8 @@ void TaskItem::setTaskErrorHandler(const TaskEndHandler &handler)
|
||||
m_taskHandler.m_errorHandler = handler;
|
||||
}
|
||||
|
||||
TaskItem TaskItem::withTimeout(const TaskItem &item, milliseconds timeout,
|
||||
const GroupEndHandler &handler)
|
||||
GroupItem GroupItem::withTimeout(const GroupItem &item, milliseconds timeout,
|
||||
const GroupEndHandler &handler)
|
||||
{
|
||||
const TimeoutTask::EndHandler taskHandler = handler
|
||||
? [handler](const milliseconds &) { handler(); } : TimeoutTask::EndHandler();
|
||||
@@ -640,7 +641,7 @@ class TaskContainer
|
||||
Q_DISABLE_COPY_MOVE(TaskContainer)
|
||||
|
||||
public:
|
||||
TaskContainer(TaskTreePrivate *taskTreePrivate, const TaskItem &task,
|
||||
TaskContainer(TaskTreePrivate *taskTreePrivate, const GroupItem &task,
|
||||
TaskNode *parentNode, TaskContainer *parentContainer)
|
||||
: m_constData(taskTreePrivate, task, parentNode, parentContainer, this) {}
|
||||
TaskAction start();
|
||||
@@ -653,7 +654,7 @@ public:
|
||||
bool isStarting() const { return isRunning() && m_runtimeData->m_startGuard.isLocked(); }
|
||||
|
||||
struct ConstData {
|
||||
ConstData(TaskTreePrivate *taskTreePrivate, const TaskItem &task, TaskNode *parentNode,
|
||||
ConstData(TaskTreePrivate *taskTreePrivate, const GroupItem &task, TaskNode *parentNode,
|
||||
TaskContainer *parentContainer, TaskContainer *thisContainer);
|
||||
~ConstData() { qDeleteAll(m_children); }
|
||||
TaskTreePrivate * const m_taskTreePrivate = nullptr;
|
||||
@@ -662,7 +663,7 @@ public:
|
||||
|
||||
const int m_parallelLimit = 1;
|
||||
const WorkflowPolicy m_workflowPolicy = WorkflowPolicy::StopOnError;
|
||||
const TaskItem::GroupHandler m_groupHandler;
|
||||
const GroupItem::GroupHandler m_groupHandler;
|
||||
const QList<TreeStorageBase> m_storageList;
|
||||
const QList<TaskNode *> m_children;
|
||||
const int m_taskCount = 0;
|
||||
@@ -693,7 +694,7 @@ class TaskNode
|
||||
Q_DISABLE_COPY_MOVE(TaskNode)
|
||||
|
||||
public:
|
||||
TaskNode(TaskTreePrivate *taskTreePrivate, const TaskItem &task,
|
||||
TaskNode(TaskTreePrivate *taskTreePrivate, const GroupItem &task,
|
||||
TaskContainer *parentContainer)
|
||||
: m_taskHandler(task.taskHandler())
|
||||
, m_container(taskTreePrivate, task, this, parentContainer)
|
||||
@@ -711,7 +712,7 @@ public:
|
||||
TaskTree *taskTree() const { return m_container.m_constData.m_taskTreePrivate->q; }
|
||||
|
||||
private:
|
||||
const TaskItem::TaskHandler m_taskHandler;
|
||||
const GroupItem::TaskHandler m_taskHandler;
|
||||
TaskContainer m_container;
|
||||
std::unique_ptr<TaskInterface> m_task;
|
||||
};
|
||||
@@ -831,16 +832,16 @@ ReturnType invokeHandler(TaskContainer *container, Handler &&handler, Args &&...
|
||||
}
|
||||
|
||||
static QList<TaskNode *> createChildren(TaskTreePrivate *taskTreePrivate, TaskContainer *container,
|
||||
const TaskItem &task)
|
||||
const GroupItem &task)
|
||||
{
|
||||
QList<TaskNode *> result;
|
||||
const QList<TaskItem> &children = task.children();
|
||||
for (const TaskItem &child : children)
|
||||
const QList<GroupItem> &children = task.children();
|
||||
for (const GroupItem &child : children)
|
||||
result.append(new TaskNode(taskTreePrivate, child, container));
|
||||
return result;
|
||||
}
|
||||
|
||||
TaskContainer::ConstData::ConstData(TaskTreePrivate *taskTreePrivate, const TaskItem &task,
|
||||
TaskContainer::ConstData::ConstData(TaskTreePrivate *taskTreePrivate, const GroupItem &task,
|
||||
TaskNode *parentNode, TaskContainer *parentContainer,
|
||||
TaskContainer *thisContainer)
|
||||
: m_taskTreePrivate(taskTreePrivate)
|
||||
@@ -1035,7 +1036,7 @@ void TaskContainer::stop()
|
||||
|
||||
void TaskContainer::invokeEndHandler()
|
||||
{
|
||||
const TaskItem::GroupHandler &groupHandler = m_constData.m_groupHandler;
|
||||
const GroupItem::GroupHandler &groupHandler = m_constData.m_groupHandler;
|
||||
if (m_runtimeData->m_successBit && groupHandler.m_doneHandler)
|
||||
invokeHandler(this, groupHandler.m_doneHandler);
|
||||
else if (!m_runtimeData->m_successBit && groupHandler.m_errorHandler)
|
||||
@@ -1539,7 +1540,7 @@ void TaskNode::invokeEndHandler(bool success)
|
||||
static QByteArray load(const QString &fileName) { ... }
|
||||
static void save(const QString &fileName, const QByteArray &array) { ... }
|
||||
|
||||
static TaskItem copyRecipe(const QString &source, const QString &destination)
|
||||
static GroupItem copyRecipe(const QString &source, const QString &destination)
|
||||
{
|
||||
struct CopyStorage { // [1] custom inter-task struct
|
||||
QByteArray content; // [2] custom inter-task data
|
||||
|
||||
@@ -123,7 +123,7 @@ enum class TaskAction
|
||||
};
|
||||
Q_ENUM_NS(TaskAction);
|
||||
|
||||
class TASKING_EXPORT TaskItem
|
||||
class TASKING_EXPORT GroupItem
|
||||
{
|
||||
public:
|
||||
// Internal, provided by QTC_DECLARE_CUSTOM_TASK
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
std::optional<WorkflowPolicy> m_workflowPolicy = {};
|
||||
};
|
||||
|
||||
QList<TaskItem> children() const { return m_children; }
|
||||
QList<GroupItem> children() const { return m_children; }
|
||||
GroupData groupData() const { return m_groupData; }
|
||||
QList<TreeStorageBase> storageList() const { return m_storageList; }
|
||||
TaskHandler taskHandler() const { return m_taskHandler; }
|
||||
@@ -169,58 +169,58 @@ protected:
|
||||
TaskHandler
|
||||
};
|
||||
|
||||
TaskItem() = default;
|
||||
TaskItem(const GroupData &data)
|
||||
GroupItem() = default;
|
||||
GroupItem(const GroupData &data)
|
||||
: m_type(Type::GroupData)
|
||||
, m_groupData(data) {}
|
||||
TaskItem(const TreeStorageBase &storage)
|
||||
GroupItem(const TreeStorageBase &storage)
|
||||
: m_type(Type::Storage)
|
||||
, m_storageList{storage} {}
|
||||
TaskItem(const TaskHandler &handler)
|
||||
GroupItem(const TaskHandler &handler)
|
||||
: m_type(Type::TaskHandler)
|
||||
, m_taskHandler(handler) {}
|
||||
void addChildren(const QList<TaskItem> &children);
|
||||
void addChildren(const QList<GroupItem> &children);
|
||||
|
||||
void setTaskSetupHandler(const TaskSetupHandler &handler);
|
||||
void setTaskDoneHandler(const TaskEndHandler &handler);
|
||||
void setTaskErrorHandler(const TaskEndHandler &handler);
|
||||
static TaskItem groupHandler(const GroupHandler &handler) { return TaskItem({handler}); }
|
||||
static TaskItem parallelLimit(int limit) { return TaskItem({{}, limit}); }
|
||||
static TaskItem workflowPolicy(WorkflowPolicy policy) { return TaskItem({{}, {}, policy}); }
|
||||
static TaskItem withTimeout(const TaskItem &item, std::chrono::milliseconds timeout,
|
||||
static GroupItem groupHandler(const GroupHandler &handler) { return GroupItem({handler}); }
|
||||
static GroupItem parallelLimit(int limit) { return GroupItem({{}, limit}); }
|
||||
static GroupItem workflowPolicy(WorkflowPolicy policy) { return GroupItem({{}, {}, policy}); }
|
||||
static GroupItem withTimeout(const GroupItem &item, std::chrono::milliseconds timeout,
|
||||
const GroupEndHandler &handler = {});
|
||||
|
||||
private:
|
||||
Type m_type = Type::Group;
|
||||
QList<TaskItem> m_children;
|
||||
QList<GroupItem> m_children;
|
||||
GroupData m_groupData;
|
||||
QList<TreeStorageBase> m_storageList;
|
||||
TaskHandler m_taskHandler;
|
||||
};
|
||||
|
||||
class TASKING_EXPORT Group : public TaskItem
|
||||
class TASKING_EXPORT Group : public GroupItem
|
||||
{
|
||||
public:
|
||||
Group(const QList<TaskItem> &children) { addChildren(children); }
|
||||
Group(std::initializer_list<TaskItem> children) { addChildren(children); }
|
||||
Group(const QList<GroupItem> &children) { addChildren(children); }
|
||||
Group(std::initializer_list<GroupItem> children) { addChildren(children); }
|
||||
|
||||
// GroupData related:
|
||||
template <typename SetupHandler>
|
||||
static TaskItem onGroupSetup(SetupHandler &&handler) {
|
||||
static GroupItem onGroupSetup(SetupHandler &&handler) {
|
||||
return groupHandler({wrapGroupSetup(std::forward<SetupHandler>(handler))});
|
||||
}
|
||||
static TaskItem onGroupDone(const GroupEndHandler &handler) {
|
||||
static GroupItem onGroupDone(const GroupEndHandler &handler) {
|
||||
return groupHandler({{}, handler});
|
||||
}
|
||||
static TaskItem onGroupError(const GroupEndHandler &handler) {
|
||||
static GroupItem onGroupError(const GroupEndHandler &handler) {
|
||||
return groupHandler({{}, {}, handler});
|
||||
}
|
||||
using TaskItem::parallelLimit; // Default: 1 (sequential). 0 means unlimited (parallel).
|
||||
using TaskItem::workflowPolicy; // Default: WorkflowPolicy::StopOnError.
|
||||
using GroupItem::parallelLimit; // Default: 1 (sequential). 0 means unlimited (parallel).
|
||||
using GroupItem::workflowPolicy; // Default: WorkflowPolicy::StopOnError.
|
||||
|
||||
TaskItem withTimeout(std::chrono::milliseconds timeout,
|
||||
const GroupEndHandler &handler = {}) const {
|
||||
return TaskItem::withTimeout(*this, timeout, handler);
|
||||
GroupItem withTimeout(std::chrono::milliseconds timeout,
|
||||
const GroupEndHandler &handler = {}) const {
|
||||
return GroupItem::withTimeout(*this, timeout, handler);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -244,31 +244,31 @@ private:
|
||||
};
|
||||
|
||||
template <typename SetupHandler>
|
||||
static TaskItem onGroupSetup(SetupHandler &&handler)
|
||||
static GroupItem onGroupSetup(SetupHandler &&handler)
|
||||
{
|
||||
return Group::onGroupSetup(std::forward<SetupHandler>(handler));
|
||||
}
|
||||
|
||||
TASKING_EXPORT TaskItem onGroupDone(const TaskItem::GroupEndHandler &handler);
|
||||
TASKING_EXPORT TaskItem onGroupError(const TaskItem::GroupEndHandler &handler);
|
||||
TASKING_EXPORT TaskItem parallelLimit(int limit);
|
||||
TASKING_EXPORT TaskItem workflowPolicy(WorkflowPolicy policy);
|
||||
TASKING_EXPORT GroupItem onGroupDone(const GroupItem::GroupEndHandler &handler);
|
||||
TASKING_EXPORT GroupItem onGroupError(const GroupItem::GroupEndHandler &handler);
|
||||
TASKING_EXPORT GroupItem parallelLimit(int limit);
|
||||
TASKING_EXPORT GroupItem workflowPolicy(WorkflowPolicy policy);
|
||||
|
||||
TASKING_EXPORT extern const TaskItem sequential;
|
||||
TASKING_EXPORT extern const TaskItem parallel;
|
||||
TASKING_EXPORT extern const GroupItem sequential;
|
||||
TASKING_EXPORT extern const GroupItem parallel;
|
||||
|
||||
TASKING_EXPORT extern const TaskItem stopOnError;
|
||||
TASKING_EXPORT extern const TaskItem continueOnError;
|
||||
TASKING_EXPORT extern const TaskItem stopOnDone;
|
||||
TASKING_EXPORT extern const TaskItem continueOnDone;
|
||||
TASKING_EXPORT extern const TaskItem stopOnFinished;
|
||||
TASKING_EXPORT extern const TaskItem finishAllAndDone;
|
||||
TASKING_EXPORT extern const TaskItem finishAllAndError;
|
||||
TASKING_EXPORT extern const GroupItem stopOnError;
|
||||
TASKING_EXPORT extern const GroupItem continueOnError;
|
||||
TASKING_EXPORT extern const GroupItem stopOnDone;
|
||||
TASKING_EXPORT extern const GroupItem continueOnDone;
|
||||
TASKING_EXPORT extern const GroupItem stopOnFinished;
|
||||
TASKING_EXPORT extern const GroupItem finishAllAndDone;
|
||||
TASKING_EXPORT extern const GroupItem finishAllAndError;
|
||||
|
||||
class TASKING_EXPORT Storage : public TaskItem
|
||||
class TASKING_EXPORT Storage : public GroupItem
|
||||
{
|
||||
public:
|
||||
Storage(const TreeStorageBase &storage) : TaskItem(storage) { }
|
||||
Storage(const TreeStorageBase &storage) : GroupItem(storage) { }
|
||||
};
|
||||
|
||||
// Synchronous invocation. Similarly to Group - isn't counted as a task inside taskCount()
|
||||
@@ -281,7 +281,7 @@ public:
|
||||
|
||||
private:
|
||||
template<typename Function>
|
||||
static QList<TaskItem> init(Function &&function) {
|
||||
static QList<GroupItem> init(Function &&function) {
|
||||
constexpr bool isInvocable = std::is_invocable_v<std::decay_t<Function>>;
|
||||
static_assert(isInvocable,
|
||||
"Sync element: The synchronous function can't take any arguments.");
|
||||
@@ -310,17 +310,17 @@ private:
|
||||
};
|
||||
|
||||
template <typename Adapter>
|
||||
class CustomTask : public TaskItem
|
||||
class CustomTask : public GroupItem
|
||||
{
|
||||
public:
|
||||
using Task = typename Adapter::Type;
|
||||
using EndHandler = std::function<void(const Task &)>;
|
||||
static Adapter *createAdapter() { return new Adapter; }
|
||||
CustomTask() : TaskItem({&createAdapter}) {}
|
||||
CustomTask() : GroupItem({&createAdapter}) {}
|
||||
template <typename SetupFunction>
|
||||
CustomTask(SetupFunction &&function, const EndHandler &done = {}, const EndHandler &error = {})
|
||||
: TaskItem({&createAdapter, wrapSetup(std::forward<SetupFunction>(function)),
|
||||
wrapEnd(done), wrapEnd(error)}) {}
|
||||
: GroupItem({&createAdapter, wrapSetup(std::forward<SetupFunction>(function)),
|
||||
wrapEnd(done), wrapEnd(error)}) {}
|
||||
|
||||
template <typename SetupFunction>
|
||||
CustomTask &onSetup(SetupFunction &&function) {
|
||||
@@ -336,14 +336,14 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
TaskItem withTimeout(std::chrono::milliseconds timeout,
|
||||
const GroupEndHandler &handler = {}) const {
|
||||
return TaskItem::withTimeout(*this, timeout, handler);
|
||||
GroupItem withTimeout(std::chrono::milliseconds timeout,
|
||||
const GroupEndHandler &handler = {}) const {
|
||||
return GroupItem::withTimeout(*this, timeout, handler);
|
||||
}
|
||||
|
||||
private:
|
||||
template<typename SetupFunction>
|
||||
static TaskItem::TaskSetupHandler wrapSetup(SetupFunction &&function) {
|
||||
static GroupItem::TaskSetupHandler wrapSetup(SetupFunction &&function) {
|
||||
static constexpr bool isDynamic = std::is_same_v<TaskAction,
|
||||
std::invoke_result_t<std::decay_t<SetupFunction>, typename Adapter::Type &>>;
|
||||
constexpr bool isVoid = std::is_same_v<void,
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
void start() {
|
||||
QTC_ASSERT(!m_taskTree, return);
|
||||
|
||||
const TaskItem task = m_filePath.needsDevice() ? remoteTask() : localTask();
|
||||
const GroupItem task = m_filePath.needsDevice() ? remoteTask() : localTask();
|
||||
m_taskTree.reset(new TaskTree({task}));
|
||||
const auto finalize = [this](bool success) {
|
||||
m_taskTree.release()->deleteLater();
|
||||
@@ -49,8 +49,8 @@ protected:
|
||||
std::unique_ptr<TaskTree> m_taskTree;
|
||||
|
||||
private:
|
||||
virtual TaskItem remoteTask() = 0;
|
||||
virtual TaskItem localTask() = 0;
|
||||
virtual GroupItem remoteTask() = 0;
|
||||
virtual GroupItem localTask() = 0;
|
||||
};
|
||||
|
||||
static void localRead(QPromise<QByteArray> &promise, const FilePath &filePath)
|
||||
@@ -84,7 +84,7 @@ signals:
|
||||
void readyRead(const QByteArray &newData);
|
||||
|
||||
private:
|
||||
TaskItem remoteTask() final {
|
||||
GroupItem remoteTask() final {
|
||||
const auto setup = [this](Process &process) {
|
||||
const QStringList args = {"if=" + m_filePath.path()};
|
||||
const FilePath dd = m_filePath.withNewPath("dd");
|
||||
@@ -96,7 +96,7 @@ private:
|
||||
};
|
||||
return ProcessTask(setup);
|
||||
}
|
||||
TaskItem localTask() final {
|
||||
GroupItem localTask() final {
|
||||
const auto setup = [this](Async<QByteArray> &async) {
|
||||
async.setConcurrentCallData(localRead, m_filePath);
|
||||
Async<QByteArray> *asyncPtr = &async;
|
||||
@@ -251,7 +251,7 @@ signals:
|
||||
void started();
|
||||
|
||||
private:
|
||||
TaskItem remoteTask() final {
|
||||
GroupItem remoteTask() final {
|
||||
const auto setup = [this](Process &process) {
|
||||
m_writeBuffer = new WriteBuffer(false, &process);
|
||||
connect(m_writeBuffer, &WriteBuffer::writeRequested, &process, &Process::writeRaw);
|
||||
@@ -272,7 +272,7 @@ private:
|
||||
};
|
||||
return ProcessTask(setup, finalize, finalize);
|
||||
}
|
||||
TaskItem localTask() final {
|
||||
GroupItem localTask() final {
|
||||
const auto setup = [this](Async<void> &async) {
|
||||
m_writeBuffer = new WriteBuffer(isBuffered(), &async);
|
||||
async.setConcurrentCallData(localWrite, m_filePath, m_writeData, m_writeBuffer);
|
||||
@@ -390,7 +390,7 @@ public:
|
||||
StreamResult m_streamResult = StreamResult::FinishedWithError;
|
||||
std::unique_ptr<TaskTree> m_taskTree;
|
||||
|
||||
TaskItem task() {
|
||||
GroupItem task() {
|
||||
if (m_streamerMode == StreamMode::Reader)
|
||||
return readerTask();
|
||||
if (m_streamerMode == StreamMode::Writer)
|
||||
@@ -399,7 +399,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
TaskItem readerTask() {
|
||||
GroupItem readerTask() {
|
||||
const auto setup = [this](FileStreamReader &reader) {
|
||||
m_readBuffer.clear();
|
||||
reader.setFilePath(m_source);
|
||||
@@ -409,14 +409,14 @@ private:
|
||||
};
|
||||
return FileStreamReaderTask(setup);
|
||||
}
|
||||
TaskItem writerTask() {
|
||||
GroupItem writerTask() {
|
||||
const auto setup = [this](FileStreamWriter &writer) {
|
||||
writer.setFilePath(m_destination);
|
||||
writer.setWriteData(m_writeBuffer);
|
||||
};
|
||||
return FileStreamWriterTask(setup);
|
||||
}
|
||||
TaskItem transferTask() {
|
||||
GroupItem transferTask() {
|
||||
const auto setup = [this](Async<void> &async) {
|
||||
async.setConcurrentCallData(transfer, m_source, m_destination);
|
||||
};
|
||||
|
||||
@@ -360,7 +360,7 @@ void TestCodeParser::scanForTests(const QSet<FilePath> &filePaths,
|
||||
|
||||
using namespace Tasking;
|
||||
|
||||
QList<TaskItem> tasks{parallelLimit(std::max(QThread::idealThreadCount() / 4, 1))};
|
||||
QList<GroupItem> tasks{parallelLimit(std::max(QThread::idealThreadCount() / 4, 1))};
|
||||
for (const FilePath &file : filteredFiles) {
|
||||
const auto setup = [this, codeParsers, file](Async<TestParseResultPtr> &async) {
|
||||
async.setConcurrentCallData(parseFileForTests, codeParsers, file);
|
||||
|
||||
@@ -347,7 +347,7 @@ void TestRunner::runTestsHelper()
|
||||
std::unique_ptr<TestOutputReader> m_outputReader;
|
||||
};
|
||||
|
||||
QList<TaskItem> tasks{finishAllAndDone};
|
||||
QList<GroupItem> tasks{finishAllAndDone};
|
||||
|
||||
for (ITestConfiguration *config : m_selectedTests) {
|
||||
QTC_ASSERT(config, continue);
|
||||
|
||||
@@ -183,7 +183,7 @@ void ClangToolRunWorker::start()
|
||||
m_filesAnalyzed.clear();
|
||||
m_filesNotAnalyzed.clear();
|
||||
|
||||
QList<TaskItem> tasks{parallelLimit(qMax(1, m_runSettings.parallelJobs()))};
|
||||
QList<GroupItem> tasks{parallelLimit(qMax(1, m_runSettings.parallelJobs()))};
|
||||
for (const AnalyzeUnit &unit : std::as_const(unitsToProcess)) {
|
||||
if (!m_diagnosticConfig.isEnabled(tool)
|
||||
&& !m_runSettings.hasConfigFileForSourceFile(unit.file)) {
|
||||
|
||||
@@ -101,9 +101,9 @@ static FilePath createOutputFilePath(const FilePath &dirPath, const FilePath &fi
|
||||
return {};
|
||||
}
|
||||
|
||||
TaskItem clangToolTask(const AnalyzeInputData &input,
|
||||
const AnalyzeSetupHandler &setupHandler,
|
||||
const AnalyzeOutputHandler &outputHandler)
|
||||
GroupItem clangToolTask(const AnalyzeInputData &input,
|
||||
const AnalyzeSetupHandler &setupHandler,
|
||||
const AnalyzeOutputHandler &outputHandler)
|
||||
{
|
||||
struct ClangToolStorage {
|
||||
QString name;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <utils/environment.h>
|
||||
|
||||
namespace Tasking { class TaskItem; }
|
||||
namespace Tasking { class GroupItem; }
|
||||
|
||||
namespace ClangTools {
|
||||
namespace Internal {
|
||||
@@ -50,9 +50,9 @@ struct AnalyzeOutputData
|
||||
using AnalyzeSetupHandler = std::function<bool()>;
|
||||
using AnalyzeOutputHandler = std::function<void(const AnalyzeOutputData &)>;
|
||||
|
||||
Tasking::TaskItem clangToolTask(const AnalyzeInputData &input,
|
||||
const AnalyzeSetupHandler &setupHandler,
|
||||
const AnalyzeOutputHandler &outputHandler);
|
||||
Tasking::GroupItem clangToolTask(const AnalyzeInputData &input,
|
||||
const AnalyzeSetupHandler &setupHandler,
|
||||
const AnalyzeOutputHandler &outputHandler);
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ClangTools
|
||||
|
||||
@@ -190,7 +190,7 @@ void DocumentClangToolRunner::run()
|
||||
vfso().update();
|
||||
const ClangDiagnosticConfig config = diagnosticConfig(runSettings.diagnosticConfigId());
|
||||
const Environment env = projectBuildEnvironment(project);
|
||||
QList<TaskItem> tasks{parallel};
|
||||
QList<GroupItem> tasks{parallel};
|
||||
const auto addClangTool = [this, &runSettings, &config, &env, &tasks](ClangToolType tool) {
|
||||
if (!toolEnabled(tool, config, runSettings))
|
||||
return;
|
||||
|
||||
@@ -450,7 +450,7 @@ void LocatorMatcher::start()
|
||||
collectorStorage->m_collector = nullptr;
|
||||
};
|
||||
|
||||
QList<TaskItem> parallelTasks {parallelLimit(d->m_parallelLimit)};
|
||||
QList<GroupItem> parallelTasks {parallelLimit(d->m_parallelLimit)};
|
||||
|
||||
const auto onSetup = [this, collectorStorage](const TreeStorage<LocatorStorage> &storage,
|
||||
int index) {
|
||||
@@ -597,7 +597,7 @@ QString ILocatorFilter::shortcutString() const
|
||||
\internal
|
||||
Sets the refresh recipe for refreshing cached data.
|
||||
*/
|
||||
void ILocatorFilter::setRefreshRecipe(const std::optional<TaskItem> &recipe)
|
||||
void ILocatorFilter::setRefreshRecipe(const std::optional<GroupItem> &recipe)
|
||||
{
|
||||
m_refreshRecipe = recipe;
|
||||
}
|
||||
@@ -606,7 +606,7 @@ void ILocatorFilter::setRefreshRecipe(const std::optional<TaskItem> &recipe)
|
||||
Returns the refresh recipe for refreshing cached data. By default, the locator filter has
|
||||
no recipe set, so that it won't be refreshed.
|
||||
*/
|
||||
std::optional<TaskItem> ILocatorFilter::refreshRecipe() const
|
||||
std::optional<GroupItem> ILocatorFilter::refreshRecipe() const
|
||||
{
|
||||
return m_refreshRecipe;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ class CORE_EXPORT LocatorMatcherTask final
|
||||
public:
|
||||
// The main task. Initial data (searchTerm) should be taken from storage.input().
|
||||
// Results reporting is done via the storage.reportOutput().
|
||||
Tasking::TaskItem task = Tasking::Group{};
|
||||
Tasking::GroupItem task = Tasking::Group{};
|
||||
|
||||
// When constructing the task, don't place the storage inside the task above.
|
||||
Tasking::TreeStorage<LocatorStorage> storage;
|
||||
@@ -270,8 +270,8 @@ protected:
|
||||
virtual void saveState(QJsonObject &object) const;
|
||||
virtual void restoreState(const QJsonObject &object);
|
||||
|
||||
void setRefreshRecipe(const std::optional<Tasking::TaskItem> &recipe);
|
||||
std::optional<Tasking::TaskItem> refreshRecipe() const;
|
||||
void setRefreshRecipe(const std::optional<Tasking::GroupItem> &recipe);
|
||||
std::optional<Tasking::GroupItem> refreshRecipe() const;
|
||||
|
||||
static bool isOldSetting(const QByteArray &state);
|
||||
|
||||
@@ -289,7 +289,7 @@ private:
|
||||
QString m_description;
|
||||
QString m_defaultShortcut;
|
||||
std::optional<QString> m_defaultSearchText;
|
||||
std::optional<Tasking::TaskItem> m_refreshRecipe;
|
||||
std::optional<Tasking::GroupItem> m_refreshRecipe;
|
||||
QKeySequence m_defaultKeySequence;
|
||||
bool m_defaultIncludedByDefault = false;
|
||||
bool m_includedByDefault = m_defaultIncludedByDefault;
|
||||
|
||||
@@ -381,7 +381,7 @@ void Locator::refresh(const QList<ILocatorFilter *> &filters)
|
||||
m_refreshingFilters = Utils::filteredUnique(m_refreshingFilters + filters);
|
||||
|
||||
using namespace Tasking;
|
||||
QList<TaskItem> tasks{parallel};
|
||||
QList<GroupItem> tasks{parallel};
|
||||
for (ILocatorFilter *filter : std::as_const(m_refreshingFilters)) {
|
||||
const auto task = filter->refreshRecipe();
|
||||
if (!task.has_value())
|
||||
|
||||
@@ -64,7 +64,7 @@ void CppProjectUpdater::update(const ProjectUpdateInfo &projectUpdateInfo,
|
||||
if (async.isResultAvailable())
|
||||
storage->projectInfo = async.result();
|
||||
};
|
||||
QList<TaskItem> tasks{parallel};
|
||||
QList<GroupItem> tasks{parallel};
|
||||
tasks.append(AsyncTask<ProjectInfo::ConstPtr>(setupInfoGenerator, onInfoGeneratorDone));
|
||||
for (QPointer<ExtraCompiler> compiler : compilers) {
|
||||
if (compiler && compiler->isDirty())
|
||||
|
||||
@@ -128,7 +128,7 @@ DiffFilesController::DiffFilesController(IDocument *document)
|
||||
outputList->resize(inputList.size());
|
||||
|
||||
using namespace std::placeholders;
|
||||
QList<TaskItem> tasks {parallel, finishAllAndDone};
|
||||
QList<GroupItem> tasks {parallel, finishAllAndDone};
|
||||
for (int i = 0; i < inputList.size(); ++i) {
|
||||
tasks.append(AsyncTask<FileData>(std::bind(setupDiff, _1, inputList.at(i)),
|
||||
std::bind(onDiffDone, _1, i)));
|
||||
|
||||
@@ -441,7 +441,7 @@ ShowController::ShowController(IDocument *document, const QString &id)
|
||||
};
|
||||
|
||||
using namespace std::placeholders;
|
||||
QList<TaskItem> tasks {parallel, continueOnDone, onGroupError(onFollowsError)};
|
||||
QList<GroupItem> tasks {parallel, continueOnDone, onGroupError(onFollowsError)};
|
||||
for (int i = 0, total = parents.size(); i < total; ++i) {
|
||||
tasks.append(ProcessTask(std::bind(setupFollow, _1, parents.at(i)),
|
||||
std::bind(onFollowDone, _1, i)));
|
||||
|
||||
@@ -137,7 +137,7 @@ QThreadPool *ExtraCompiler::extraCompilerThreadPool()
|
||||
return s_extraCompilerThreadPool();
|
||||
}
|
||||
|
||||
TaskItem ExtraCompiler::compileFileItem()
|
||||
GroupItem ExtraCompiler::compileFileItem()
|
||||
{
|
||||
return taskItemImpl(fromFileProvider());
|
||||
}
|
||||
@@ -326,7 +326,7 @@ ProcessExtraCompiler::ProcessExtraCompiler(const Project *project, const FilePat
|
||||
ExtraCompiler(project, source, targets, parent)
|
||||
{ }
|
||||
|
||||
TaskItem ProcessExtraCompiler::taskItemImpl(const ContentProvider &provider)
|
||||
GroupItem ProcessExtraCompiler::taskItemImpl(const ContentProvider &provider)
|
||||
{
|
||||
const auto setupTask = [=](Async<FileNameToContentsHash> &async) {
|
||||
async.setThreadPool(extraCompilerThreadPool());
|
||||
|
||||
@@ -24,7 +24,7 @@ class QPromise;
|
||||
class QThreadPool;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Tasking { class TaskItem; }
|
||||
namespace Tasking { class GroupItem; }
|
||||
namespace Utils { class Process; }
|
||||
|
||||
namespace ProjectExplorer {
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
Utils::FilePaths targets() const;
|
||||
void forEachTarget(std::function<void(const Utils::FilePath &)> func) const;
|
||||
|
||||
Tasking::TaskItem compileFileItem();
|
||||
Tasking::GroupItem compileFileItem();
|
||||
void compileFile();
|
||||
bool isDirty() const;
|
||||
void block();
|
||||
@@ -75,7 +75,7 @@ private:
|
||||
void compileContent(const QByteArray &content);
|
||||
void compileImpl(const ContentProvider &provider);
|
||||
void compileIfDirty();
|
||||
virtual Tasking::TaskItem taskItemImpl(const ContentProvider &provider) = 0;
|
||||
virtual Tasking::GroupItem taskItemImpl(const ContentProvider &provider) = 0;
|
||||
|
||||
const std::unique_ptr<ExtraCompilerPrivate> d;
|
||||
};
|
||||
@@ -101,7 +101,7 @@ protected:
|
||||
virtual Tasks parseIssues(const QByteArray &stdErr);
|
||||
|
||||
private:
|
||||
Tasking::TaskItem taskItemImpl(const ContentProvider &provider) final;
|
||||
Tasking::GroupItem taskItemImpl(const ContentProvider &provider) final;
|
||||
void runInThread(QPromise<FileNameToContentsHash> &promise,
|
||||
const Utils::FilePath &cmd, const Utils::FilePath &workDir,
|
||||
const QStringList &args, const ContentProvider &provider,
|
||||
|
||||
@@ -330,7 +330,7 @@ void QMakeStep::doRun()
|
||||
emit buildConfiguration()->buildDirectoryInitialized();
|
||||
};
|
||||
|
||||
QList<TaskItem> processList = {ProcessTask(setupQMake, onProcessDone, onProcessError)};
|
||||
QList<GroupItem> processList = {ProcessTask(setupQMake, onProcessDone, onProcessError)};
|
||||
if (m_runMakeQmake)
|
||||
processList << ProcessTask(setupMakeQMake, onProcessDone, onProcessError);
|
||||
processList << onGroupDone(onDone);
|
||||
|
||||
@@ -90,11 +90,11 @@ public:
|
||||
|
||||
private:
|
||||
Group deployRecipe();
|
||||
TaskItem checkDirTask();
|
||||
TaskItem removeDirTask();
|
||||
TaskItem uploadTask();
|
||||
TaskItem chmodTask(const DeployableFile &file);
|
||||
TaskItem chmodTree();
|
||||
GroupItem checkDirTask();
|
||||
GroupItem removeDirTask();
|
||||
GroupItem uploadTask();
|
||||
GroupItem chmodTask(const DeployableFile &file);
|
||||
GroupItem chmodTree();
|
||||
|
||||
enum class CheckResult { RemoveDir, SkipRemoveDir, Abort };
|
||||
CheckResult m_checkResult = CheckResult::Abort;
|
||||
@@ -117,7 +117,7 @@ QList<DeployableFile> collectFilesToUpload(const DeployableFile &deployable)
|
||||
return collected;
|
||||
}
|
||||
|
||||
TaskItem QnxDeployQtLibrariesDialogPrivate::checkDirTask()
|
||||
GroupItem QnxDeployQtLibrariesDialogPrivate::checkDirTask()
|
||||
{
|
||||
const auto setupHandler = [this](Process &process) {
|
||||
m_deployLogWindow->appendPlainText(Tr::tr("Checking existence of \"%1\"")
|
||||
@@ -145,7 +145,7 @@ TaskItem QnxDeployQtLibrariesDialogPrivate::checkDirTask()
|
||||
return ProcessTask(setupHandler, doneHandler, errorHandler);
|
||||
}
|
||||
|
||||
TaskItem QnxDeployQtLibrariesDialogPrivate::removeDirTask()
|
||||
GroupItem QnxDeployQtLibrariesDialogPrivate::removeDirTask()
|
||||
{
|
||||
const auto setupHandler = [this](Process &process) {
|
||||
if (m_checkResult != CheckResult::RemoveDir)
|
||||
@@ -162,7 +162,7 @@ TaskItem QnxDeployQtLibrariesDialogPrivate::removeDirTask()
|
||||
return ProcessTask(setupHandler, {}, errorHandler);
|
||||
}
|
||||
|
||||
TaskItem QnxDeployQtLibrariesDialogPrivate::uploadTask()
|
||||
GroupItem QnxDeployQtLibrariesDialogPrivate::uploadTask()
|
||||
{
|
||||
const auto setupHandler = [this](FileTransfer &transfer) {
|
||||
if (m_deployableFiles.isEmpty()) {
|
||||
@@ -196,7 +196,7 @@ TaskItem QnxDeployQtLibrariesDialogPrivate::uploadTask()
|
||||
return FileTransferTask(setupHandler, {}, errorHandler);
|
||||
}
|
||||
|
||||
TaskItem QnxDeployQtLibrariesDialogPrivate::chmodTask(const DeployableFile &file)
|
||||
GroupItem QnxDeployQtLibrariesDialogPrivate::chmodTask(const DeployableFile &file)
|
||||
{
|
||||
const auto setupHandler = [=](Process &process) {
|
||||
process.setCommand({m_device->filePath("chmod"),
|
||||
@@ -215,7 +215,7 @@ TaskItem QnxDeployQtLibrariesDialogPrivate::chmodTask(const DeployableFile &file
|
||||
return ProcessTask(setupHandler, {}, errorHandler);
|
||||
}
|
||||
|
||||
TaskItem QnxDeployQtLibrariesDialogPrivate::chmodTree()
|
||||
GroupItem QnxDeployQtLibrariesDialogPrivate::chmodTree()
|
||||
{
|
||||
const auto setupChmodHandler = [=](TaskTree &tree) {
|
||||
QList<DeployableFile> filesToChmod;
|
||||
@@ -223,7 +223,7 @@ TaskItem QnxDeployQtLibrariesDialogPrivate::chmodTree()
|
||||
if (file.isExecutable())
|
||||
filesToChmod << file;
|
||||
}
|
||||
QList<TaskItem> chmodList{finishAllAndDone, parallelLimit(MaxConcurrentStatCalls)};
|
||||
QList<GroupItem> chmodList{finishAllAndDone, parallelLimit(MaxConcurrentStatCalls)};
|
||||
for (const DeployableFile &file : std::as_const(filesToChmod)) {
|
||||
QTC_ASSERT(file.isValid(), continue);
|
||||
chmodList.append(chmodTask(file));
|
||||
|
||||
@@ -75,13 +75,13 @@ public:
|
||||
using FilesToStat = std::function<QList<DeployableFile>(UploadStorage *)>;
|
||||
using StatEndHandler
|
||||
= std::function<void(UploadStorage *, const DeployableFile &, const QDateTime &)>;
|
||||
TaskItem statTask(UploadStorage *storage, const DeployableFile &file,
|
||||
StatEndHandler statEndHandler);
|
||||
TaskItem statTree(const TreeStorage<UploadStorage> &storage, FilesToStat filesToStat,
|
||||
StatEndHandler statEndHandler);
|
||||
TaskItem uploadTask(const TreeStorage<UploadStorage> &storage);
|
||||
TaskItem chmodTask(const DeployableFile &file);
|
||||
TaskItem chmodTree(const TreeStorage<UploadStorage> &storage);
|
||||
GroupItem statTask(UploadStorage *storage, const DeployableFile &file,
|
||||
StatEndHandler statEndHandler);
|
||||
GroupItem statTree(const TreeStorage<UploadStorage> &storage, FilesToStat filesToStat,
|
||||
StatEndHandler statEndHandler);
|
||||
GroupItem uploadTask(const TreeStorage<UploadStorage> &storage);
|
||||
GroupItem chmodTask(const DeployableFile &file);
|
||||
GroupItem chmodTree(const TreeStorage<UploadStorage> &storage);
|
||||
|
||||
IncrementalDeployment m_incremental = IncrementalDeployment::NotSupported;
|
||||
bool m_ignoreMissingFiles = false;
|
||||
@@ -156,9 +156,9 @@ QDateTime GenericDirectUploadStep::timestampFromStat(const DeployableFile &file,
|
||||
return QDateTime::fromSecsSinceEpoch(secsSinceEpoch);
|
||||
}
|
||||
|
||||
TaskItem GenericDirectUploadStep::statTask(UploadStorage *storage,
|
||||
const DeployableFile &file,
|
||||
StatEndHandler statEndHandler)
|
||||
GroupItem GenericDirectUploadStep::statTask(UploadStorage *storage,
|
||||
const DeployableFile &file,
|
||||
StatEndHandler statEndHandler)
|
||||
{
|
||||
const auto setupHandler = [=](Process &process) {
|
||||
// We'd like to use --format=%Y, but it's not supported by busybox.
|
||||
@@ -173,13 +173,13 @@ TaskItem GenericDirectUploadStep::statTask(UploadStorage *storage,
|
||||
return ProcessTask(setupHandler, endHandler, endHandler);
|
||||
}
|
||||
|
||||
TaskItem GenericDirectUploadStep::statTree(const TreeStorage<UploadStorage> &storage,
|
||||
FilesToStat filesToStat, StatEndHandler statEndHandler)
|
||||
GroupItem GenericDirectUploadStep::statTree(const TreeStorage<UploadStorage> &storage,
|
||||
FilesToStat filesToStat, StatEndHandler statEndHandler)
|
||||
{
|
||||
const auto setupHandler = [=](TaskTree &tree) {
|
||||
UploadStorage *storagePtr = storage.activeStorage();
|
||||
const QList<DeployableFile> files = filesToStat(storagePtr);
|
||||
QList<TaskItem> statList{finishAllAndDone, parallelLimit(MaxConcurrentStatCalls)};
|
||||
QList<GroupItem> statList{finishAllAndDone, parallelLimit(MaxConcurrentStatCalls)};
|
||||
for (const DeployableFile &file : std::as_const(files)) {
|
||||
QTC_ASSERT(file.isValid(), continue);
|
||||
statList.append(statTask(storagePtr, file, statEndHandler));
|
||||
@@ -189,7 +189,7 @@ TaskItem GenericDirectUploadStep::statTree(const TreeStorage<UploadStorage> &sto
|
||||
return TaskTreeTask(setupHandler);
|
||||
}
|
||||
|
||||
TaskItem GenericDirectUploadStep::uploadTask(const TreeStorage<UploadStorage> &storage)
|
||||
GroupItem GenericDirectUploadStep::uploadTask(const TreeStorage<UploadStorage> &storage)
|
||||
{
|
||||
const auto setupHandler = [this, storage](FileTransfer &transfer) {
|
||||
if (storage->filesToUpload.isEmpty()) {
|
||||
@@ -229,7 +229,7 @@ TaskItem GenericDirectUploadStep::uploadTask(const TreeStorage<UploadStorage> &s
|
||||
return FileTransferTask(setupHandler, {}, errorHandler);
|
||||
}
|
||||
|
||||
TaskItem GenericDirectUploadStep::chmodTask(const DeployableFile &file)
|
||||
GroupItem GenericDirectUploadStep::chmodTask(const DeployableFile &file)
|
||||
{
|
||||
const auto setupHandler = [=](Process &process) {
|
||||
process.setCommand({deviceConfiguration()->filePath("chmod"),
|
||||
@@ -248,7 +248,7 @@ TaskItem GenericDirectUploadStep::chmodTask(const DeployableFile &file)
|
||||
return ProcessTask(setupHandler, {}, errorHandler);
|
||||
}
|
||||
|
||||
TaskItem GenericDirectUploadStep::chmodTree(const TreeStorage<UploadStorage> &storage)
|
||||
GroupItem GenericDirectUploadStep::chmodTree(const TreeStorage<UploadStorage> &storage)
|
||||
{
|
||||
const auto setupChmodHandler = [=](TaskTree &tree) {
|
||||
QList<DeployableFile> filesToChmod;
|
||||
@@ -256,7 +256,7 @@ TaskItem GenericDirectUploadStep::chmodTree(const TreeStorage<UploadStorage> &st
|
||||
if (file.isExecutable())
|
||||
filesToChmod << file;
|
||||
}
|
||||
QList<TaskItem> chmodList{finishAllAndDone, parallelLimit(MaxConcurrentStatCalls)};
|
||||
QList<GroupItem> chmodList{finishAllAndDone, parallelLimit(MaxConcurrentStatCalls)};
|
||||
for (const DeployableFile &file : std::as_const(filesToChmod)) {
|
||||
QTC_ASSERT(file.isValid(), continue);
|
||||
chmodList.append(chmodTask(file));
|
||||
|
||||
@@ -34,20 +34,20 @@ public:
|
||||
|
||||
QStringList commandsToTest() const;
|
||||
|
||||
TaskItem echoTask(const QString &contents) const;
|
||||
TaskItem unameTask() const;
|
||||
TaskItem gathererTask() const;
|
||||
TaskItem transferTask(FileTransferMethod method,
|
||||
const TreeStorage<TransferStorage> &storage) const;
|
||||
TaskItem transferTasks() const;
|
||||
TaskItem commandTask(const QString &commandName) const;
|
||||
TaskItem commandTasks() const;
|
||||
GroupItem echoTask(const QString &contents) const;
|
||||
GroupItem unameTask() const;
|
||||
GroupItem gathererTask() const;
|
||||
GroupItem transferTask(FileTransferMethod method,
|
||||
const TreeStorage<TransferStorage> &storage) const;
|
||||
GroupItem transferTasks() const;
|
||||
GroupItem commandTask(const QString &commandName) const;
|
||||
GroupItem commandTasks() const;
|
||||
|
||||
GenericLinuxDeviceTester *q = nullptr;
|
||||
IDevice::Ptr m_device;
|
||||
std::unique_ptr<TaskTree> m_taskTree;
|
||||
QStringList m_extraCommands;
|
||||
QList<TaskItem> m_extraTests;
|
||||
QList<GroupItem> m_extraTests;
|
||||
};
|
||||
|
||||
QStringList GenericLinuxDeviceTesterPrivate::commandsToTest() const
|
||||
@@ -90,7 +90,7 @@ QStringList GenericLinuxDeviceTesterPrivate::commandsToTest() const
|
||||
return commands;
|
||||
}
|
||||
|
||||
TaskItem GenericLinuxDeviceTesterPrivate::echoTask(const QString &contents) const
|
||||
GroupItem GenericLinuxDeviceTesterPrivate::echoTask(const QString &contents) const
|
||||
{
|
||||
const auto setup = [this, contents](Process &process) {
|
||||
emit q->progressMessage(Tr::tr("Sending echo to device..."));
|
||||
@@ -114,7 +114,7 @@ TaskItem GenericLinuxDeviceTesterPrivate::echoTask(const QString &contents) cons
|
||||
return ProcessTask(setup, done, error);
|
||||
}
|
||||
|
||||
TaskItem GenericLinuxDeviceTesterPrivate::unameTask() const
|
||||
GroupItem GenericLinuxDeviceTesterPrivate::unameTask() const
|
||||
{
|
||||
const auto setup = [this](Process &process) {
|
||||
emit q->progressMessage(Tr::tr("Checking kernel version..."));
|
||||
@@ -136,7 +136,7 @@ TaskItem GenericLinuxDeviceTesterPrivate::unameTask() const
|
||||
};
|
||||
}
|
||||
|
||||
TaskItem GenericLinuxDeviceTesterPrivate::gathererTask() const
|
||||
GroupItem GenericLinuxDeviceTesterPrivate::gathererTask() const
|
||||
{
|
||||
const auto setup = [this](DeviceUsedPortsGatherer &gatherer) {
|
||||
emit q->progressMessage(Tr::tr("Checking if specified ports are available..."));
|
||||
@@ -164,8 +164,8 @@ TaskItem GenericLinuxDeviceTesterPrivate::gathererTask() const
|
||||
};
|
||||
}
|
||||
|
||||
TaskItem GenericLinuxDeviceTesterPrivate::transferTask(FileTransferMethod method,
|
||||
const TreeStorage<TransferStorage> &storage) const
|
||||
GroupItem GenericLinuxDeviceTesterPrivate::transferTask(FileTransferMethod method,
|
||||
const TreeStorage<TransferStorage> &storage) const
|
||||
{
|
||||
const auto setup = [this, method](FileTransfer &transfer) {
|
||||
emit q->progressMessage(Tr::tr("Checking whether \"%1\" works...")
|
||||
@@ -216,7 +216,7 @@ TaskItem GenericLinuxDeviceTesterPrivate::transferTask(FileTransferMethod method
|
||||
return FileTransferTestTask(setup, done, error);
|
||||
}
|
||||
|
||||
TaskItem GenericLinuxDeviceTesterPrivate::transferTasks() const
|
||||
GroupItem GenericLinuxDeviceTesterPrivate::transferTasks() const
|
||||
{
|
||||
TreeStorage<TransferStorage> storage;
|
||||
return Group {
|
||||
@@ -231,7 +231,7 @@ TaskItem GenericLinuxDeviceTesterPrivate::transferTasks() const
|
||||
};
|
||||
}
|
||||
|
||||
TaskItem GenericLinuxDeviceTesterPrivate::commandTask(const QString &commandName) const
|
||||
GroupItem GenericLinuxDeviceTesterPrivate::commandTask(const QString &commandName) const
|
||||
{
|
||||
const auto setup = [this, commandName](Process &process) {
|
||||
emit q->progressMessage(Tr::tr("%1...").arg(commandName));
|
||||
@@ -252,9 +252,9 @@ TaskItem GenericLinuxDeviceTesterPrivate::commandTask(const QString &commandName
|
||||
return ProcessTask(setup, done, error);
|
||||
}
|
||||
|
||||
TaskItem GenericLinuxDeviceTesterPrivate::commandTasks() const
|
||||
GroupItem GenericLinuxDeviceTesterPrivate::commandTasks() const
|
||||
{
|
||||
QList<TaskItem> tasks {continueOnError};
|
||||
QList<GroupItem> tasks {continueOnError};
|
||||
tasks.append(onGroupSetup([this] {
|
||||
emit q->progressMessage(Tr::tr("Checking if required commands are available..."));
|
||||
}));
|
||||
@@ -279,7 +279,7 @@ void GenericLinuxDeviceTester::setExtraCommandsToTest(const QStringList &extraCo
|
||||
d->m_extraCommands = extraCommands;
|
||||
}
|
||||
|
||||
void GenericLinuxDeviceTester::setExtraTests(const QList<TaskItem> &extraTests)
|
||||
void GenericLinuxDeviceTester::setExtraTests(const QList<GroupItem> &extraTests)
|
||||
{
|
||||
d->m_extraTests = extraTests;
|
||||
}
|
||||
@@ -295,7 +295,7 @@ void GenericLinuxDeviceTester::testDevice(const IDevice::Ptr &deviceConfiguratio
|
||||
d->m_taskTree.release()->deleteLater();
|
||||
};
|
||||
|
||||
QList<TaskItem> taskItems = {
|
||||
QList<GroupItem> taskItems = {
|
||||
d->echoTask("Hello"), // No quoting necessary
|
||||
d->echoTask("Hello Remote World!"), // Checks quoting, too.
|
||||
d->unameTask(),
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
|
||||
namespace Tasking { class TaskItem; }
|
||||
namespace Tasking { class GroupItem; }
|
||||
|
||||
namespace RemoteLinux {
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
~GenericLinuxDeviceTester() override;
|
||||
|
||||
void setExtraCommandsToTest(const QStringList &extraCommands);
|
||||
void setExtraTests(const QList<Tasking::TaskItem> &extraTests);
|
||||
void setExtraTests(const QList<Tasking::GroupItem> &extraTests);
|
||||
void testDevice(const ProjectExplorer::IDevice::Ptr &deviceConfiguration) override;
|
||||
void stopTest() override;
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ public:
|
||||
private:
|
||||
bool isDeploymentNecessary() const final;
|
||||
Group deployRecipe() final;
|
||||
TaskItem mkdirTask();
|
||||
TaskItem transferTask();
|
||||
GroupItem mkdirTask();
|
||||
GroupItem transferTask();
|
||||
|
||||
mutable FilesToTransfer m_files;
|
||||
bool m_ignoreMissingFiles = false;
|
||||
@@ -85,7 +85,7 @@ bool RsyncDeployStep::isDeploymentNecessary() const
|
||||
return !m_files.empty();
|
||||
}
|
||||
|
||||
TaskItem RsyncDeployStep::mkdirTask()
|
||||
GroupItem RsyncDeployStep::mkdirTask()
|
||||
{
|
||||
const auto setupHandler = [this](Process &process) {
|
||||
QStringList remoteDirs;
|
||||
@@ -113,7 +113,7 @@ TaskItem RsyncDeployStep::mkdirTask()
|
||||
return ProcessTask(setupHandler, {}, errorHandler);
|
||||
}
|
||||
|
||||
TaskItem RsyncDeployStep::transferTask()
|
||||
GroupItem RsyncDeployStep::transferTask()
|
||||
{
|
||||
const auto setupHandler = [this](FileTransfer &transfer) {
|
||||
transfer.setTransferMethod(FileTransferMethod::Rsync);
|
||||
|
||||
@@ -55,8 +55,8 @@ private:
|
||||
QString remoteFilePath() const;
|
||||
bool isDeploymentNecessary() const final;
|
||||
Group deployRecipe() final;
|
||||
TaskItem uploadTask();
|
||||
TaskItem installTask();
|
||||
GroupItem uploadTask();
|
||||
GroupItem installTask();
|
||||
|
||||
FilePath m_packageFilePath;
|
||||
};
|
||||
@@ -71,7 +71,7 @@ bool TarPackageDeployStep::isDeploymentNecessary() const
|
||||
return hasLocalFileChanged(DeployableFile(m_packageFilePath, {}));
|
||||
}
|
||||
|
||||
TaskItem TarPackageDeployStep::uploadTask()
|
||||
GroupItem TarPackageDeployStep::uploadTask()
|
||||
{
|
||||
const auto setupHandler = [this](FileTransfer &transfer) {
|
||||
const FilesToTransfer files {{m_packageFilePath,
|
||||
@@ -90,7 +90,7 @@ TaskItem TarPackageDeployStep::uploadTask()
|
||||
return FileTransferTask(setupHandler, doneHandler, errorHandler);
|
||||
}
|
||||
|
||||
TaskItem TarPackageDeployStep::installTask()
|
||||
GroupItem TarPackageDeployStep::installTask()
|
||||
{
|
||||
const auto setupHandler = [this](Process &process) {
|
||||
const QString cmdLine = QLatin1String("cd / && tar xvf ") + remoteFilePath()
|
||||
|
||||
@@ -135,7 +135,7 @@ void UpdateInfoPlugin::startCheckForUpdates()
|
||||
d->m_updateOutput = process.cleanedStdOut();
|
||||
};
|
||||
|
||||
QList<TaskItem> tasks { ProcessTask(setupUpdate, updateDone) };
|
||||
QList<GroupItem> tasks { ProcessTask(setupUpdate, updateDone) };
|
||||
if (d->m_settings.checkForQtVersions) {
|
||||
const auto setupPackages = [doSetup](Process &process) {
|
||||
doSetup(process, {"se", "qt[.]qt[0-9][.][0-9]+$", "-g", "*=false,ifw.package.*=true"});
|
||||
|
||||
@@ -45,7 +45,7 @@ TreeStorage<QString> VcsBaseDiffEditorController::inputStorage() const
|
||||
return d->m_inputStorage;
|
||||
}
|
||||
|
||||
TaskItem VcsBaseDiffEditorController::postProcessTask()
|
||||
GroupItem VcsBaseDiffEditorController::postProcessTask()
|
||||
{
|
||||
const auto setupDiffProcessor = [this](Async<QList<FileData>> &async) {
|
||||
const QString *storage = inputStorage().activeStorage();
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
|
||||
protected:
|
||||
Tasking::TreeStorage<QString> inputStorage() const;
|
||||
Tasking::TaskItem postProcessTask();
|
||||
Tasking::GroupItem postProcessTask();
|
||||
|
||||
void setupCommand(Utils::Process &process, const QStringList &args) const;
|
||||
|
||||
|
||||
@@ -197,8 +197,8 @@ public:
|
||||
TASKING_DECLARE_TASK(TickAndDoneTask, TickAndDoneTaskAdapter);
|
||||
|
||||
template <typename SharedBarrierType>
|
||||
TaskItem createBarrierAdvance(const TreeStorage<CustomStorage> &storage,
|
||||
const SharedBarrierType &barrier, int taskId)
|
||||
GroupItem createBarrierAdvance(const TreeStorage<CustomStorage> &storage,
|
||||
const SharedBarrierType &barrier, int taskId)
|
||||
{
|
||||
return TickAndDoneTask([storage, barrier, taskId](TickAndDone &tickAndDone) {
|
||||
tickAndDone.setInterval(1ms);
|
||||
@@ -253,7 +253,7 @@ void tst_Tasking::testTree_data()
|
||||
};
|
||||
|
||||
const auto createTask = [storage, setupTask, setupDone, setupError](
|
||||
int taskId, bool successTask, milliseconds timeout = 0ms) -> TaskItem {
|
||||
int taskId, bool successTask, milliseconds timeout = 0ms) -> GroupItem {
|
||||
if (successTask)
|
||||
return TestTask(setupTask(taskId, timeout), setupDone(taskId), setupError(taskId));
|
||||
const Group root {
|
||||
|
||||
@@ -500,7 +500,7 @@ void tst_Async::mapReduce_data()
|
||||
using SetupHandler = std::function<void(Async<int> &task, int input)>;
|
||||
using DoneHandler = std::function<void()>;
|
||||
|
||||
const auto createTask = [=](const TaskItem &executeMode,
|
||||
const auto createTask = [=](const GroupItem &executeMode,
|
||||
const SetupHandler &setupHandler,
|
||||
const DoneHandler &doneHandler) {
|
||||
return Group {
|
||||
|
||||
@@ -128,7 +128,7 @@ private slots:
|
||||
async.setConcurrentCallData(generate, parentPath, templateFile, s_treeDepth);
|
||||
};
|
||||
};
|
||||
QList<TaskItem> tasks {parallel};
|
||||
QList<GroupItem> tasks {parallel};
|
||||
for (int i = 0; i < tasksCount; ++i) {
|
||||
const QString dirName = QString("%1%2").arg(s_dirPrefix).arg(i);
|
||||
QVERIFY(parentDir.mkdir(dirName));
|
||||
@@ -153,7 +153,7 @@ private slots:
|
||||
async.setConcurrentCallData(removeTree, parentPath);
|
||||
};
|
||||
};
|
||||
QList<TaskItem> tasks {parallel};
|
||||
QList<GroupItem> tasks {parallel};
|
||||
const int tasksCount = QThread::idealThreadCount();
|
||||
for (int i = 0; i < tasksCount; ++i) {
|
||||
const QString dirName = QString("%1%2").arg(s_dirPrefix).arg(i);
|
||||
|
||||
@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
std::unique_ptr<TaskTree> taskTree;
|
||||
|
||||
const auto createTask = [](TaskWidget *widget) -> TaskItem {
|
||||
const auto createTask = [](TaskWidget *widget) -> GroupItem {
|
||||
const auto setupTask = [](TaskWidget *widget) {
|
||||
return [widget](milliseconds &taskObject) {
|
||||
taskObject = milliseconds{widget->busyTime() * 1000};
|
||||
|
||||
@@ -158,7 +158,7 @@ void GroupWidget::updateExecuteMode()
|
||||
m_executeCombo->setCurrentIndex(m_executeCombo->findData((int)m_executeMode));
|
||||
}
|
||||
|
||||
TaskItem GroupWidget::executeMode() const
|
||||
GroupItem GroupWidget::executeMode() const
|
||||
{
|
||||
return m_executeMode == ExecuteMode::Sequential ? sequential : parallel;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ void GroupWidget::updateWorkflowPolicy()
|
||||
m_workflowCombo->setCurrentIndex(m_workflowCombo->findData((int)m_workflowPolicy));
|
||||
}
|
||||
|
||||
TaskItem GroupWidget::workflowPolicy() const
|
||||
GroupItem GroupWidget::workflowPolicy() const
|
||||
{
|
||||
return Tasking::workflowPolicy(m_workflowPolicy);
|
||||
}
|
||||
|
||||
@@ -62,10 +62,10 @@ public:
|
||||
GroupWidget();
|
||||
|
||||
void setExecuteMode(ExecuteMode mode);
|
||||
Tasking::TaskItem executeMode() const;
|
||||
Tasking::GroupItem executeMode() const;
|
||||
|
||||
void setWorkflowPolicy(Tasking::WorkflowPolicy policy);
|
||||
Tasking::TaskItem workflowPolicy() const;
|
||||
Tasking::GroupItem workflowPolicy() const;
|
||||
|
||||
private:
|
||||
void updateExecuteMode();
|
||||
|
||||
Reference in New Issue
Block a user