[Development] QFutureInterface

Bauer, Christian christianbauer at siemens.com
Fri Dec 4 10:49:04 CET 2015

Hi Marc,

First: thanks for your suggestions.

> 1. Inherit your runnable from QRunnable and QFutureInterface<T>
>    In the ctor, call QFI::setRunnable(this).
>2. Create an instance of your runnable, call runnable.future() to get the
>    QFuture end
> 3. Schedule the runnable on a thread pool (cf. QConcurrent::run(QThreadPool*
>    for how to implant that into the QFutureInterface so work stealing works).
> 4. From within runnable::run() operate the QFutureInterface API 5. Use 
>the  QFuture obtained in (2) as you'd use an other future.
So the QPackagedTask would be a Runnable that you run on the thread pool, and that runnable represents a QPromise at the same time.

Maybe I am missing something here, but I don't think this solves my problem.
In my scenario, the QPackagedTask does not produce the result. The task only triggers something else that will - in some point in the future - produce the actual result. By the time the result is produced, the original QPackagedTask does not even exist anymore. 

The idea of the patch is to support decoupling the Promise (QFI) from the task that I schedule via QConcurrent::run().
Some task will call the promise and set the result, instead of the promise receiving the return value of the task.

I could provide a code example if this helps...


More information about the Development mailing list