Lets say I have a vector of 100 elements and Func1 and Func2. In the single threaded version Func1 process vector elements and when Func1 finishes, Func2 must start a different process on elements.
I'm curious to know if I utilize QtConcurrent::map
in the following order, in which order actually Func1 and Func2 will execute?
QFuture<void> future;
future = QtConcurrent::map(vector, Func1);
future = QtConcurrent::map(vector, Func2);
I must mention that using future.waitForFinished()
will block my application main thread which I don't want.
future = QtConcurrent::map(vector, Func1);
future.waitForFinished();
future = QtConcurrent::map(vector, Func2);
Also I don't want to execute those QtConcurrent::map
in a secondary thread and do the future.waitForFinished()
there, because in that approach I will lose one of my threads in threadpool.
So, the question is do tasks added by QtConcurrent::map
execute in order?
EDIT
In both single threaded and multi-threaded approaches Func2 must run only after Func1 finishes processing all elements.