PDA

View Full Version : QFuture waitForFinished() and result()



dlib
10th April 2012, 21:49
Hi all, I am wondering what the differences between QFuture methods waitForFinished and result exactly are. Do not both methods wait for results from computation in the different threads to finish? Thanks and regards.

Spitfire
11th April 2012, 16:07
Basically yes.

The difference is that waitForFinished() only tests for thread state (returns when no longer running) when result() checks also for internal result and returns when thread has finished or result is ready.



// waitForFinished():
while (d->state & Running)
d->waitCondition.wait(&d->m_mutex);

// waitForResult():
while ((d->state & Running) && d->internal_isResultReadyAt(waitIndex) == false)
d->waitCondition.wait(&d->m_mutex);
}