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:
Jarek Kobus
2024-01-13 12:37:26 +01:00
parent 14f6954026
commit 7e7318d47d
4 changed files with 87 additions and 4 deletions

View File

@@ -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
)

View File

@@ -16,6 +16,8 @@ QtcLibrary {
"tasking_global.h",
"tasktree.cpp",
"tasktree.h",
"tasktreerunner.cpp",
"tasktreerunner.h",
]
Export {

View 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

View 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