Details
-
User Story
-
Resolution: Done
-
P2: Important
-
None
-
6.0
-
None
-
13
-
Qt6_Foundation_ Sprint 14, Qt6_Foundation_Sprint 15, Qt6_Foundation_Sprint 16
Description
QtConcurrent::run(Function f) could accept the Function that takes QPromise<T> as an argument. In this way we would enable progress reporting, canceling or suspending the task from inside working thread. Alternatively, instead of overloading the run() method, we could add a new one called e.g. runWithPromise(). The Function could be of the form:
auto future = QtConcurrent::runWithPromise([] (QPromise<T>& implicitPromise, /* my args follow */ ...) { // Note: implicitPromise is the object provided by QtConcurrent, not by the user // do something with implicitPromise, this would update the future returned by QtConcurrent::run(). });
Most probably it wasn't enabled so far because QFutureInterface<T> was not an official public API. But since we are now enabling it with QPromise, we may do it!
The idea was initially suggested here: (https://codereview.qt-project.org/c/qt/qtbase/+/300337), with some follow up comments. Potentially it may influence the API or usage of QPromise.
Update: looking at what Creator has it seems like it may make sense to do it also for other QtConcurrent methods.
Attachments
Issue Links
- relates to
-
QTBUG-84868 Confront the QFuture and QtConcurrent API with Creator utils
-
- Closed
-