[Development] QFutureInterface

Bauer, Christian christianbauer at siemens.com
Fri Nov 27 13:45:28 CET 2015


Hi Marc,

> You should be able to develop a QPromise/QPackagedTask with the current QFutureInterface already. 
> At least as long as it's attached to some > QThreadPool. 
> What, exactly, are you trying to do that requires a patch to QFI?
I am not aware of any QPackagedTask in Qt, only of packaged_task in C++11. Or do you mean RunFunctionTaskBase?

The QFuture(Interface) represents the return value of a function, e.g., the one passed in QtConcurrent::run.
The QFuture(Interface) will execute the function on a thread pool. As soon as this function returns, the return value is stored and the state of the promise set to Finished.

Our (simplified) problem is: this function does not return a value but feeds an asynchronous pipeline. When the pipeline processing is done it will call
 promise.SetResult(); promise.reportResult();
and only then the future should be notified of the result.

We can achieve this by using a custom waitForFinished() in our future wrapper, instead of using the QFuture waitForFinished. But this requires access to the QWaitCondition of the QFutureInterface.


I hope the use case is clear. The C++11 future/promise achieves exactly this, and we are using the QFuture in a similar way.

Thanks
 Christian



More information about the Development mailing list