-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.10
-
None
As pointed in https://bugreports.qt.io/browse/QTBUG-140786 the continuation functor needs access to either its QPromise or some sort of std::stop_token otherwise is impossible to know if the chain was canceled in the functor.
Mandatory code snippet
//... auto future = someFutureWork().then([&](QPromise<void> &myPromise, const QFuture<int> &previousResults) { // either (optionally) pass QPromise Q_UNUSED(previousResults); for (int i = 0; i < (1 << 31) && !myPromise.isCanceled(); ++i) { QThread::msleep(100); // simulate some heavy work } myPromise.finish(); }).then([&](std::stop_token stopToken) { // or use std::stop_token, though it's a C++20 feature ... for (int i = 0; i < (1 << 31) && !stopToken.stop_requested(); ++i) { QThread::msleep(100); // simulate some heavy work } }); future.cancelChain(); //...
- relates to
-
QTBUG-140786 QFuture::cancelChain doesn't set the cancel info to all chained futures/promises
-
- In Progress
-