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.
Printable View
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.
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.
Code:
// 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); }