QAbstractTaskTreeRunner Class

An abstract base class for various task tree controllers. More...

Header: #include <qtasktreerunner.h>
Inherits: QObject
Inherited By:

QMappedTaskTreeRunner, QParallelTaskTreeRunner, QSequentialTaskTreeRunner, and QSingleTaskTreeRunner

Note: All functions in this class are reentrant.

Public Types

Public Functions

QAbstractTaskTreeRunner(QObject *parent = nullptr)
virtual ~QAbstractTaskTreeRunner() override
virtual void cancel() = 0
virtual bool isRunning() const = 0
virtual void reset() = 0

Signals

void aboutToStart(QTaskTree *taskTree)
void done(QtTaskTree::DoneWith result, QTaskTree *taskTree)

Detailed Description

The task tree runner manages the lifetime of the underlying QTaskTree used to execute the given recipe.

The following table summarizes the differences between various QAbstractTaskTreeRunner subclasses:

Class nameDescription
QSingleTaskTreeRunnerManages single task tree execution. The QSingleTaskTreeRunner::start() method unconditionally starts the passed recipe, resetting any task tree that might be running. Only one task tree can be executing at a time.
QSequentialTaskTreeRunnerManages sequential task tree executions. The QSequentialTaskTreeRunner::enqueue() method starts the passed recipe if the task tree runner is idle. Otherwise, the recipe is enqueued. When the current task finishes, the runner executes the dequeued recipe sequentially. Only one task tree can be executing at a time.
QParallelTaskTreeRunnerManages parallel task tree executions. The QParallelTaskTreeRunner::start() method unconditionally starts the passed recipe and keeps any possibly running task trees in parallel.
QMappedTaskTreeRunnerManages mapped task tree executions. The QMappedTaskTreeRunner::start() method unconditionally starts the passed recipe for a given key, resetting any possibly running task tree with the same key. Task trees with different keys are unaffected and continue their execution.

Member Type Documentation

[alias] QAbstractTaskTreeRunner::TreeDoneHandler

Type alias for std::function<void(const QTaskTree &, QtTaskTree::DoneWith)>.

The TreeDoneHandler is an optional argument of task tree runners' functions scheduling the task tree execution. The function is called when the task tree runner's recipe finished the execution. The access to the QTaskTree and recipe's result is via the passed arguments.

The task tree runners accept also handlers in a shortened form of std::function<void(const QTaskTree &)>, std::function<void(QtTaskTree::DoneWith)>, or std::function<void(void)>.

[alias] QAbstractTaskTreeRunner::TreeSetupHandler

Type alias for std::function<void(QTaskTree &)>.

The TreeSetupHandler is an optional argument of task tree runners' functions scheduling the task tree execution. The function is called when the task tree runner is about to execute it's recipe. The access to the QTaskTree is via the passed argument.

The task tree runners accept also handlers in a shortened form of std::function<void(void)>.

Member Function Documentation

QAbstractTaskTreeRunner::QAbstractTaskTreeRunner(QObject *parent = nullptr)

Constructs an abstract task tree runner for the given parent.

[override virtual noexcept] QAbstractTaskTreeRunner::~QAbstractTaskTreeRunner()

Destroys the abstract task tree runner. Any possibly running task tree is deleted and any scheduled task tree execution is skipped.

See also ~QTaskTree().

[signal] void QAbstractTaskTreeRunner::aboutToStart(QTaskTree *taskTree)

This signal is emitted whenever task tree runner is about to start the taskTree.

See also QTaskTree::started().

[pure virtual] void QAbstractTaskTreeRunner::cancel()

Cancels all running task trees. Calls task trees' done handlers and emits done() signals with DoneWith::Cancel. Any scheduled and not started task tree executions are removed.

[signal] void QAbstractTaskTreeRunner::done(QtTaskTree::DoneWith result, QTaskTree *taskTree)

This signal is emitted whenever task tree runner finishes the execution of the taskTree with a result.

See also QTaskTree::done().

[pure virtual] bool QAbstractTaskTreeRunner::isRunning() const

Returns whether the task tree runner is currently executing any task tree.

[pure virtual] void QAbstractTaskTreeRunner::reset()

Resets all running task trees. No task tree's done handlers are called nor done() signals are emitted. Any scheduled and not started task tree executions are removed.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.