void ThreadWatcher2::run() {
updateTimer
= new QTimer(this);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(timeoutHandler()));
connect(thread[0], SIGNAL(finished()), this, SLOT(finishedHandler0()));
connect(thread[1], SIGNAL(finished()), this, SLOT(finishedHandler1()));
connect(thread[2], SIGNAL(finished()), this, SLOT(finishedHandler2()));
connect(thread[3], SIGNAL(finished()), this, SLOT(finishedHandler3()));
connect(thread[4], SIGNAL(finished()), this, SLOT(finishedHandler4()));
connect(thread[5], SIGNAL(finished()), this, SLOT(finishedHandler5()));
updateTimer->start(delay);
status->setText("Status: Done");
}
void ThreadWatcher2::timeoutHandler() {
for (int i=0; i<6; i++) {
if (alive[i])
window[i]->update(); }
if (threadsLeft==0) {
if (control[1])
else if (control[0]) {
updateTimer->stop();
lock->lock();
condition->wait(lock);
lock->unlock();
updateTimer->start(delay);}
}
void ThreadWatcher2::finishedHandler0() {
disconnect(SIGNAL(finished()), this, SLOT(finishedHandler0()));
alive[0] = false;
threadsLeft--;
seconds[0] = (float)runTime[0] / 1000.0f;
time[0]->setText
("Time: "+QString::number(seconds
[0],
'g',
3));
}
void ThreadWatcher2::finishedHandler1() {
.
.
.
void ThreadWatcher2::run() {
updateTimer = new QTimer(this);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(timeoutHandler()));
connect(thread[0], SIGNAL(finished()), this, SLOT(finishedHandler0()));
connect(thread[1], SIGNAL(finished()), this, SLOT(finishedHandler1()));
connect(thread[2], SIGNAL(finished()), this, SLOT(finishedHandler2()));
connect(thread[3], SIGNAL(finished()), this, SLOT(finishedHandler3()));
connect(thread[4], SIGNAL(finished()), this, SLOT(finishedHandler4()));
connect(thread[5], SIGNAL(finished()), this, SLOT(finishedHandler5()));
updateTimer->start(delay);
QThread::exec();
status->setText("Status: Done");
}
void ThreadWatcher2::timeoutHandler() {
for (int i=0; i<6; i++) {
if (alive[i])
window[i]->update(); }
if (threadsLeft==0) {
QThread::exit(0); }
if (control[1])
QThread::exit(1);
else if (control[0]) {
updateTimer->stop();
lock->lock();
condition->wait(lock);
lock->unlock();
updateTimer->start(delay);}
}
void ThreadWatcher2::finishedHandler0() {
disconnect(SIGNAL(finished()), this, SLOT(finishedHandler0()));
alive[0] = false;
threadsLeft--;
seconds[0] = (float)runTime[0] / 1000.0f;
time[0]->setText("Time: "+QString::number(seconds[0],'g',3));
}
void ThreadWatcher2::finishedHandler1() {
.
.
.
To copy to clipboard, switch view to plain text mode
Bookmarks