forked from qt-creator/qt-creator
TaskTree: Introduce TaskTreeRunner
This addresses the 30th point in the bugreport below. Task-number: QTCREATORBUG-28741 Change-Id: Ifa157311b3aae413b19075d36e11c75e6066881d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -2,12 +2,18 @@ add_qtc_library(Tasking OBJECT
|
||||
# Never add dependencies to non-Qt libraries for this library
|
||||
DEPENDS Qt::Concurrent Qt::Core Qt::Network
|
||||
SOURCES
|
||||
barrier.cpp barrier.h
|
||||
barrier.cpp
|
||||
barrier.h
|
||||
concurrentcall.h
|
||||
networkquery.cpp networkquery.h
|
||||
qprocesstask.cpp qprocesstask.h
|
||||
networkquery.cpp
|
||||
networkquery.h
|
||||
qprocesstask.cpp
|
||||
qprocesstask.h
|
||||
tasking_global.h
|
||||
tasktree.cpp tasktree.h
|
||||
tasktree.cpp
|
||||
tasktree.h
|
||||
tasktreerunner.cpp
|
||||
tasktreerunner.h
|
||||
EXPLICIT_MOC
|
||||
networkquery.h
|
||||
)
|
||||
|
||||
@@ -16,6 +16,8 @@ QtcLibrary {
|
||||
"tasking_global.h",
|
||||
"tasktree.cpp",
|
||||
"tasktree.h",
|
||||
"tasktreerunner.cpp",
|
||||
"tasktreerunner.h",
|
||||
]
|
||||
|
||||
Export {
|
||||
|
||||
33
src/libs/solutions/tasking/tasktreerunner.cpp
Normal file
33
src/libs/solutions/tasking/tasktreerunner.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2024 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "tasktreerunner.h"
|
||||
|
||||
#include "tasktree.h"
|
||||
|
||||
namespace Tasking {
|
||||
|
||||
TaskTreeRunner::~TaskTreeRunner() = default;
|
||||
|
||||
void TaskTreeRunner::start(const Group &recipe)
|
||||
{
|
||||
m_taskTree.reset(new TaskTree(recipe));
|
||||
connect(m_taskTree.get(), &TaskTree::done, this, [this](DoneWith result) {
|
||||
m_taskTree.release()->deleteLater();
|
||||
emit done(result);
|
||||
});
|
||||
m_taskTree->start();
|
||||
}
|
||||
|
||||
void TaskTreeRunner::stop()
|
||||
{
|
||||
if (m_taskTree)
|
||||
m_taskTree->stop();
|
||||
}
|
||||
|
||||
void TaskTreeRunner::reset()
|
||||
{
|
||||
m_taskTree.reset();
|
||||
}
|
||||
|
||||
} // namespace Tasking
|
||||
42
src/libs/solutions/tasking/tasktreerunner.h
Normal file
42
src/libs/solutions/tasking/tasktreerunner.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright (C) 2024 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "tasking_global.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace Tasking {
|
||||
|
||||
enum class DoneWith;
|
||||
class Group;
|
||||
class TaskTree;
|
||||
|
||||
class TASKING_EXPORT TaskTreeRunner : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
~TaskTreeRunner();
|
||||
|
||||
bool isRunning() const { return bool(m_taskTree); }
|
||||
|
||||
// When task tree is running it resets the old task tree.
|
||||
void start(const Group &recipe);
|
||||
|
||||
// TODO: rename to cancel(), also in TaskTree API, adapt docs.
|
||||
// When task tree is running it emits done(DoneWith::Cancel) synchronously.
|
||||
void stop();
|
||||
|
||||
// No done() signal is emitted.
|
||||
void reset();
|
||||
|
||||
signals:
|
||||
void done(DoneWith result);
|
||||
|
||||
private:
|
||||
std::unique_ptr<TaskTree> m_taskTree;
|
||||
};
|
||||
|
||||
} // namespace Tasking
|
||||
Reference in New Issue
Block a user