Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-35137

Make QFuture usable beyond concurrent framework, add QPromise, QError

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P4: Low
    • None
    • None
    • None

    Description

      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?

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              mmutz Marc Mutz
              bkatreniak Branislav Katreniak
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes