On Sep 26, 2011, at 3:40 PM, ext Thiago Macieira wrote:
> 
> BTW, if anyone has suggestions on how to write cancellable synchronous code 
> that is also non-blocking (co-threads?), I'd love to read some more. Vala 
> (the 
> language) has some concepts in that area, but I don't know how they're 
> implemented.


I've been toying around with a new API for QtConcurrent that supports the 
"threaded synchronous" style with cancellation. If using futures it could look 
like this:

future f = run([]{
        contents = QFile::readAll(fileName);

        process(contents);
});

f.cancel() // cancels the task at any point.

QFile:readAll() would register itself with the future and be implemented on top 
of a suitable async API that supports cancellation. How does it return from the 
readAll() call? By throwing a QCancelledException.

Morten

_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback

Reply via email to