[Interest] Lifetime of data involved in QtConcurrent functions

Stephen Chu stephen at ju-ju.com
Sun Sep 30 01:02:02 CEST 2012

I am implementing some threaded task with QtConcurrent framework, 
specifically mapped() function.

I have some questions regarding the lifetime of various data used:

Say I have the following code:

     QList<MyData> myList;
     ... // code to connect myFutureWatcher to slots
     auto future = QtConcurrent::mapped(myList, myMapFunction);

Does mapped() make a copy of myList? Or do I have to make sure it lasts 
until future.isFinished()?

Also, is it OK for future to go out of scope? Or do I once again have to 
keep it alive until it's all finished?


More information about the Interest mailing list