for (int id=1;id<=guidata.numbers_of_workerthreads;id++)
{
Worker *worker = new Worker(&guidata,ui,id,&m_c,&mutex_file,&mutex_count);
worker->moveToThread(thread);
//connect events from worker<-> threads
connect(worker,
SIGNAL(error
(QString)),
this,
SLOT(errorString
(QString)));
connect(thread, SIGNAL(started()), worker, SLOT(comets_to_use())); // when i start the thread it automaticly runs my slot that i specify
connect(this, SIGNAL(shut_down_threads()), worker ,SLOT(on_shut_down_threads()));
connect(worker, SIGNAL(finished()), thread, SLOT(quit()));
connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
}
}
for (int id=1;id<=guidata.numbers_of_workerthreads;id++)
{
QThread *thread = new QThread;
Worker *worker = new Worker(&guidata,ui,id,&m_c,&mutex_file,&mutex_count);
worker->moveToThread(thread);
//connect events from worker<-> threads
connect(worker, SIGNAL(error(QString)), this, SLOT(errorString(QString)));
connect(thread, SIGNAL(started()), worker, SLOT(comets_to_use())); // when i start the thread it automaticly runs my slot that i specify
connect(this, SIGNAL(shut_down_threads()), worker ,SLOT(on_shut_down_threads()));
connect(worker, SIGNAL(finished()), thread, SLOT(quit()));
connect(worker, SIGNAL(finished()), worker, SLOT(deleteLater()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks