On Mar 4, 2013, at 11:56 PM, Thiago Macieira <[email protected]> wrote:
> 
> Oh, and if you want simple, one more thing occurred to me:
> 
>  runFunction([]() { main(); then(); });
> 
> If you need the return value:
>  runFunction([]() { then(main()); });
> 
> I will not accept "C++11 isn't available for everyone" as a reason to add a 
> more complicated API. The API should be designed for C++11 use and later made 
> to work with C++98, with as little modification as possible.

I think this is the direction we should go in: build the future API around 
C++11 lambdas.

This reduces the need for QFuture and especially QFutureWatcher. Thiago pointed 
out the waiting case above. Instead of connecting to 
QFutureWatcher::finished(), create a signal and emit when the work is done:

MyObject::asyncWork()
{
    runFunction([]() { 
        Result result = doWork();
        emit done(result); // signal on MyObject
    });
}

Morten

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to