Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Parallel calculation leads to random corruption of the results
nulluse last edited by nulluse
I am learning Qt parallel namespace on the Mandelbrot set test app.
When I run regular single-threaded calculation over the data vector, the result is always the same.
But when the parallel calculation runs using QtConcurrent::map, the results become corrupt after about 300,000 elements of the vector and corruption is seemingly random (the last screen shows that no corruption occurred even though the 1st and 2nd were corrupt).
Can anyone please point me in the right direction of what I am doing wrong?
You don't wait for map to finish before updating the picture.
nulluse last edited by
Excellent, I totally mis-read the tutorials and was convinced that assigning to the future was supposed to do that.
Now this works perfect:
QFutureWatcher<void> fw; fw.setFuture(QtConcurrent::map(vec, mandelbrot)); fw.waitForFinished();
Since you want to do multithreading, why not use the finished signal ? Beware, you'll have to refactor the code a bit.