aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2022-10-31 12:08:59 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2022-11-18 16:34:59 +0000
commit34a7ada66b7c0485bb6143ec174a55257f38306b (patch)
treed9859f08dde4e58c2833aaf3a7e7255b3967135a /src/libs
parentb4142684276e4fc67f13c9b3eacf398a1eb6b6b6 (diff)
AsyncTask: Add async task adapter for task tree
Change-Id: I9fd90fef0d9eedfaca6e405ada5aa26006f06e33 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/utils/asynctask.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libs/utils/asynctask.h b/src/libs/utils/asynctask.h
index 3b46b5aa8b..b2c7e6c50e 100644
--- a/src/libs/utils/asynctask.h
+++ b/src/libs/utils/asynctask.h
@@ -8,6 +8,7 @@
#include "futuresynchronizer.h"
#include "qtcassert.h"
#include "runextensions.h"
+#include "tasktree.h"
#include <QFutureWatcher>
@@ -77,4 +78,18 @@ private:
QFutureWatcher<ResultType> m_watcher;
};
+template <typename ResultType>
+class AsyncTaskAdapter : public Tasking::TaskAdapter<AsyncTask<ResultType>>
+{
+public:
+ AsyncTaskAdapter() {
+ this->connect(this->task(), &AsyncTaskBase::done, this, [this] {
+ emit this->done(!this->task()->isCanceled());
+ });
+ }
+ void start() final { this->task()->start(); }
+};
+
} // namespace Utils
+
+QTC_DECLARE_CUSTOM_TEMPLATE_TASK(Async, AsyncTaskAdapter);