Thanks. I used your code to construct the thing below. It looks not so hot but work just how I need.
// call this function to start
void MainWindow::on_btn_iter_clicked()
{
maxIter = 5;
s = fieldSizeI / threadsAmount;
NewIteration();
}
void MainWindow::NewIteration() {
std::vector<QFutureWatcher<void> *> watchers (threadsAmount);
for (size_t i = 0; i < threadsAmount; ++i) {
watchers[i] = new QFutureWatcher<void>;
connect (watchers[i], SIGNAL (finished()), this, SLOT (S()));
}
typedef std::vector<QFuture<void> > futures (threadsAmount);
for (size_t i = 0; i < threadsAmount; ++i) {
futures[i] = QtConcurrent::run(field, &CA_Field::PerformIteration,
i*s, (i+1)*s );
watchers[i]->setFuture(futures[i]);
}
}
void MainWindow::S() {
++workCounter;
if (workCounter == threadsAmount) {
field->AdoptNewState();
workCounter = 0;
(--maxIter != 0) ? NewIteration() : UpdateHexMap();
}
}