Skip to content

Commit

Permalink
Merge pull request rlancaste#122 from rlancaste/parallelabort
Browse files Browse the repository at this point in the history
Parallelabort
  • Loading branch information
rlancaste authored Jul 28, 2022
2 parents dfa5c03 + fa4d40f commit 69986bd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
25 changes: 14 additions & 11 deletions stellarsolver/stellarsolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,11 @@ StellarSolver::StellarSolver(ProcessType type, const FITSImage::Statistic &image

StellarSolver::~StellarSolver()
{
// These lines make sure that before the StellarSolver is deleted, all parallel threads (if any) are shut down
for(auto &solver : parallelSolvers)
disconnect(solver, &ExtractorSolver::finished, this, &StellarSolver::finishParallelSolve);

for(auto &solver : parallelSolvers)
{
solver->abort();
solver->wait();
}

abortAndWait();
}

void StellarSolver::registerMetaTypes()
Expand Down Expand Up @@ -638,14 +635,20 @@ bool StellarSolver::pixelToWCS(const QPointF &pixelPoint, FITSImage::wcs_point &
//This is the abort method. It works in different ways for the different solvers.
void StellarSolver::abort()
{
for(auto &solver : parallelSolvers) {
for(auto &solver : parallelSolvers)
solver->abort();
solver->wait();
}
if(m_ExtractorSolver) {
if(m_ExtractorSolver)
m_ExtractorSolver->abort();
}

//This is the abort and wait method, it is useful if you want the solver to be all shut down before moving on
void StellarSolver::abortAndWait()
{
abort();
for(auto &solver : parallelSolvers)
solver->wait();
if(m_ExtractorSolver)
m_ExtractorSolver->wait();
}
}

//This method checks all the solvers and the internal running boolean to determine if anything is running.
Expand Down
5 changes: 5 additions & 0 deletions stellarsolver/stellarsolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ class StellarSolver : public QObject
*/
void abort();

/**
* @brief abort will abort the Star Extraction or Plate Solving process and wait synchronously till that is done.
*/
void abortAndWait();

/**
* @brief setParameters sets the Parameters for the StellarSolver based on a Parameters object you set up.
* @param parameters The Parameters object
Expand Down
2 changes: 1 addition & 1 deletion tester/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ bool MainWindow::prepareForProcesses()
if(QMessageBox::question(this, "Abort?", "StellarSolver is extracting sources now. Abort it?") == QMessageBox::No)
return false;
}
stellarSolver.abort();
stellarSolver.abortAndWait();
}

numberOfTrials = ui->trials->value();
Expand Down

0 comments on commit 69986bd

Please sign in to comment.