void MainWindow::findpifunc()
{
tabstack = new QVector<pi_display_box*>; //a vector containing a number of tabs (to view the pi calculation) // pi_display_box is a customised qtextedit
threadstack
= new QVector <QThread
*>;
//a vector containing a number of threads objstack
= new QVector <Thr_object
*>;
//a vector of corresponding objects
for (int corestorun=0;corestorun<core_box->currentText().toUInt();corestorun++) //for the number of cores to run the calculation upon
{
tabstack->append(new pi_display_box); //add display widget to stack
threadstack
->append
(new QThread);
//add a new qthread
objstack->append(new Thr_object); //add a new object
pi_bar
->addTab
(tabstack
->at
(corestorun
),
"Core " + QString::number(corestorun
+1));
//opens new tab with display widget }
for (int corestorun=0;corestorun<core_box->currentText().toUInt();corestorun++)
{
objstack->at(corestorun)->moveToThread(threadstack->at(corestorun)); //move the object to the relevant thread
connect (threadstack->at(corestorun),SIGNAL(started()),objstack->at(corestorun),SLOT(process())); //connect the started signal to process where the thread execution occurs
//when thread finishes
connect (objstack->at(corestorun),SIGNAL(finished()),threadstack->at(corestorun),SLOT(quit())); //deleting thread etc
connect (objstack->at(corestorun),SIGNAL(finished()),objstack->at(corestorun),SLOT(deleteLater()));
connect (threadstack->at(corestorun),SIGNAL(finished()),threadstack->at(corestorun),SLOT(deleteLater()));
objstack->at(corestorun)->settextdisplay(tabstack->at(corestorun),pidigits_box->currentText()); //a few arguments loaded into the object
threadstack->at(corestorun)->start(); //begin the code execution
}
}
void MainWindow::findpifunc()
{
tabstack = new QVector<pi_display_box*>; //a vector containing a number of tabs (to view the pi calculation) // pi_display_box is a customised qtextedit
threadstack = new QVector <QThread*>; //a vector containing a number of threads
objstack = new QVector <Thr_object*>; //a vector of corresponding objects
for (int corestorun=0;corestorun<core_box->currentText().toUInt();corestorun++) //for the number of cores to run the calculation upon
{
tabstack->append(new pi_display_box); //add display widget to stack
threadstack->append(new QThread); //add a new qthread
objstack->append(new Thr_object); //add a new object
pi_bar->addTab(tabstack->at(corestorun),"Core " + QString::number(corestorun+1)); //opens new tab with display widget
}
for (int corestorun=0;corestorun<core_box->currentText().toUInt();corestorun++)
{
objstack->at(corestorun)->moveToThread(threadstack->at(corestorun)); //move the object to the relevant thread
connect (threadstack->at(corestorun),SIGNAL(started()),objstack->at(corestorun),SLOT(process())); //connect the started signal to process where the thread execution occurs
//when thread finishes
connect (objstack->at(corestorun),SIGNAL(finished()),threadstack->at(corestorun),SLOT(quit())); //deleting thread etc
connect (objstack->at(corestorun),SIGNAL(finished()),objstack->at(corestorun),SLOT(deleteLater()));
connect (threadstack->at(corestorun),SIGNAL(finished()),threadstack->at(corestorun),SLOT(deleteLater()));
objstack->at(corestorun)->settextdisplay(tabstack->at(corestorun),pidigits_box->currentText()); //a few arguments loaded into the object
threadstack->at(corestorun)->start(); //begin the code execution
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks