Priority: P4: Low
Affects Version/s: None
Fix Version/s: None
Component/s: Core: Containers and Algorithms
Class QFuture is part of QtCore, but it is usable only with QtConcurrent.
Class QDBusReply has similar functionality but is usable only with QtDBus.
I suggest to make QFuture more useful.
I see these additional ways how to create QFuture:
- method future() in new template class QPromise<T> (similar to std::promise). QPromise is derived from Object. Deleting QPromise means cancel. Setting result on QPromise finishes the returned future.
- QFuture<int>::ready(47) - creates immediately ready future
- from QDBusReply - it is a future, just implemented in QtDBus
I propose also to extend the QFuture with option to be finished with error. We need new class QError similar to QDBusError.
There are classes std:promise and std:future, but they do not provide integration with qt event loop and QObject threading model.
But I would like to have the functionality of C++ standard proposal n3558.
I believe that QPromise, QFuture and QError would make the class KJob in KDE frameworks obsolete.
Qt DBus could reply to dbus call asynchronously (or with error) if the method wrapped by QDBusAdaptor returns QFuture. The current api QDBusContext().setDelayedReply(true) is dbus specific and not reusable.
I am willing to work on patches, discuss details. But is there interest in such code in QtCore?