summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qfuture.h
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2025-01-28 18:34:26 +0100
committerIvan Solovev <ivan.solovev@qt.io>2025-02-11 12:19:50 +0100
commitcdc71532ec2b5d29995f0f34249ebe2174b28c9c (patch)
tree1abf9afc52d297c06877b0f41ae4231026575767 /src/corelib/thread/qfuture.h
parent3164746eb09a34818cfa874ae248d01e0c4f5d74 (diff)
Add QFuture::cancelChain()
This method should be used on a future returned from the long continuation chain, if this chain needs to be canceled altogether. To achieve it, this commit introduces a pointer to the parent data. That pointer is set when setContinuation() is called, and cleaned when the parent is completed and calls its runContinuation() method. This allows the code in cancelChain() to simply move up the chain as long as the parent pointer is valid, and cancel each of the continuations. The commit also moves the QFIB::cancel() implementation into QFIBP::cancelImpl(), so that it can be reused in the new method, and introduces an enum for cancellation options, to address the differences in the behavior between these two methods. Note that the approach consistently works only on the last QFuture of the chain, because the already-executed continuations might clear their continuation data, which makes navigating down the chain inconsistent. [ChangeLog][QtCore][QFuture] Added QFuture::cancelChain(). Fixes: QTBUG-130662 Change-Id: Ic0949ed30a2f54f99597e95b3951fda6bfb9a0be Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/thread/qfuture.h')
-rw-r--r--src/corelib/thread/qfuture.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/thread/qfuture.h b/src/corelib/thread/qfuture.h
index 4aacd97f233..3c75365d096 100644
--- a/src/corelib/thread/qfuture.h
+++ b/src/corelib/thread/qfuture.h
@@ -63,6 +63,7 @@ public:
void cancel() { d.cancel(); }
bool isCanceled() const { return d.isCanceled(); }
+ void cancelChain() { d.cancelChain(); }
#if QT_DEPRECATED_SINCE(6, 0)
QT_DEPRECATED_VERSION_X_6_0("Use setSuspended() instead.")