summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2019-08-14 11:45:34 +0200
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2019-08-14 11:45:34 +0200
commitd9261bdb05cd0863a2c3747c812871dbb851646e (patch)
treed1a81110e3fe213747a58f236e021a085417f663 /src
parent9a58b7451179ed512f975bc4c90fb71f172250b9 (diff)
downloadastra-d9261bdb05cd0863a2c3747c812871dbb851646e.tar.gz
astra-d9261bdb05cd0863a2c3747c812871dbb851646e.tar.bz2
astra-d9261bdb05cd0863a2c3747c812871dbb851646e.tar.xz
astra-d9261bdb05cd0863a2c3747c812871dbb851646e.zip
Replace signal-based abort handling by query-based handling
The abort handling is currently only used to process Ctrl-C from Matlab. Since Matlab R2019a, it appears that calling utIsInterruptPending() from a thread other than the main thread will crash. The previous approach of checking utIsInterruptPending() in a thread, and then signalling the running algorithm was therefore broken.
Diffstat (limited to 'src')
-rw-r--r--src/Algorithm.cpp3
-rw-r--r--src/AsyncAlgorithm.cpp6
-rw-r--r--src/BackProjectionAlgorithm.cpp2
-rw-r--r--src/CudaCglsAlgorithm3D.cpp7
-rw-r--r--src/CudaReconstructionAlgorithm2D.cpp7
-rw-r--r--src/CudaSirtAlgorithm3D.cpp7
-rw-r--r--src/Globals.cpp14
-rw-r--r--src/SartAlgorithm.cpp4
-rw-r--r--src/SirtAlgorithm.cpp4
9 files changed, 18 insertions, 36 deletions
diff --git a/src/Algorithm.cpp b/src/Algorithm.cpp
index f6514fc..41da987 100644
--- a/src/Algorithm.cpp
+++ b/src/Algorithm.cpp
@@ -33,7 +33,7 @@ namespace astra {
//----------------------------------------------------------------------------------------
// Constructor
-CAlgorithm::CAlgorithm() : m_bShouldAbort(false), configCheckData(0) {
+CAlgorithm::CAlgorithm() : configCheckData(0) {
}
@@ -60,4 +60,5 @@ boost::any CAlgorithm::getInformation(std::string _sIdentifier)
return std::string("not found");
}
+
} // namespace astra
diff --git a/src/AsyncAlgorithm.cpp b/src/AsyncAlgorithm.cpp
index 82f23ec..7b82376 100644
--- a/src/AsyncAlgorithm.cpp
+++ b/src/AsyncAlgorithm.cpp
@@ -161,10 +161,4 @@ void CAsyncAlgorithm::runWrapped(int _iNrIterations)
m_bDone = true;
}
-void CAsyncAlgorithm::signalAbort()
-{
- if (m_pAlg)
- m_pAlg->signalAbort();
-}
-
}
diff --git a/src/BackProjectionAlgorithm.cpp b/src/BackProjectionAlgorithm.cpp
index 2e35bdd..97bdb33 100644
--- a/src/BackProjectionAlgorithm.cpp
+++ b/src/BackProjectionAlgorithm.cpp
@@ -167,8 +167,6 @@ void CBackProjectionAlgorithm::run(int _iNrIterations)
// check initialized
ASTRA_ASSERT(m_bIsInitialized);
- m_bShouldAbort = false;
-
CDataProjectorInterface* pBackProjector;
pBackProjector = dispatchDataProjector(
diff --git a/src/CudaCglsAlgorithm3D.cpp b/src/CudaCglsAlgorithm3D.cpp
index 686c5b1..2977c80 100644
--- a/src/CudaCglsAlgorithm3D.cpp
+++ b/src/CudaCglsAlgorithm3D.cpp
@@ -274,13 +274,6 @@ void CCudaCglsAlgorithm3D::run(int _iNrIterations)
}
//----------------------------------------------------------------------------------------
-void CCudaCglsAlgorithm3D::signalAbort()
-{
- if (m_bIsInitialized && m_pCgls) {
- m_pCgls->signalAbort();
- }
-}
-
bool CCudaCglsAlgorithm3D::getResidualNorm(float32& _fNorm)
{
if (!m_bIsInitialized || !m_pCgls)
diff --git a/src/CudaReconstructionAlgorithm2D.cpp b/src/CudaReconstructionAlgorithm2D.cpp
index d584fc8..1e81390 100644
--- a/src/CudaReconstructionAlgorithm2D.cpp
+++ b/src/CudaReconstructionAlgorithm2D.cpp
@@ -341,13 +341,6 @@ void CCudaReconstructionAlgorithm2D::run(int _iNrIterations)
ASTRA_ASSERT(ok);
}
-void CCudaReconstructionAlgorithm2D::signalAbort()
-{
- if (m_bIsInitialized && m_pAlgo) {
- m_pAlgo->signalAbort();
- }
-}
-
bool CCudaReconstructionAlgorithm2D::getResidualNorm(float32& _fNorm)
{
if (!m_bIsInitialized || !m_pAlgo)
diff --git a/src/CudaSirtAlgorithm3D.cpp b/src/CudaSirtAlgorithm3D.cpp
index 2483704..17fea67 100644
--- a/src/CudaSirtAlgorithm3D.cpp
+++ b/src/CudaSirtAlgorithm3D.cpp
@@ -275,13 +275,6 @@ void CCudaSirtAlgorithm3D::run(int _iNrIterations)
}
//----------------------------------------------------------------------------------------
-void CCudaSirtAlgorithm3D::signalAbort()
-{
- if (m_bIsInitialized && m_pSirt) {
- m_pSirt->signalAbort();
- }
-}
-
bool CCudaSirtAlgorithm3D::getResidualNorm(float32& _fNorm)
{
if (!m_bIsInitialized || !m_pSirt)
diff --git a/src/Globals.cpp b/src/Globals.cpp
index b983e3c..5f32482 100644
--- a/src/Globals.cpp
+++ b/src/Globals.cpp
@@ -40,5 +40,19 @@ _AstraExport bool cudaAvailable() {
#endif
}
+
+static bool (*pShouldAbortHook)(void) = 0;
+
+void setShouldAbortHook(bool (*_pShouldAbortHook)(void)) {
+ pShouldAbortHook = _pShouldAbortHook;
+}
+
+bool shouldAbort() {
+ if (pShouldAbortHook && (*pShouldAbortHook)())
+ return true;
+
+ return false;
+}
+
}
diff --git a/src/SartAlgorithm.cpp b/src/SartAlgorithm.cpp
index 94460ba..7a3947d 100644
--- a/src/SartAlgorithm.cpp
+++ b/src/SartAlgorithm.cpp
@@ -288,8 +288,6 @@ void CSartAlgorithm::run(int _iNrIterations)
// check initialized
ASTRA_ASSERT(m_bIsInitialized);
- m_bShouldAbort = false;
-
// data projectors
CDataProjectorInterface* pFirstForwardProjector;
CDataProjectorInterface* pForwardProjector;
@@ -334,7 +332,7 @@ void CSartAlgorithm::run(int _iNrIterations)
// iteration loop
- for (int iIteration = 0; iIteration < _iNrIterations && !m_bShouldAbort; ++iIteration) {
+ for (int iIteration = 0; iIteration < _iNrIterations && !shouldAbort(); ++iIteration) {
int iProjection = m_piProjectionOrder[m_iIterationCount % m_iProjectionCount];
diff --git a/src/SirtAlgorithm.cpp b/src/SirtAlgorithm.cpp
index 3ea0a24..f08e8b2 100644
--- a/src/SirtAlgorithm.cpp
+++ b/src/SirtAlgorithm.cpp
@@ -199,8 +199,6 @@ void CSirtAlgorithm::run(int _iNrIterations)
// check initialized
ASTRA_ASSERT(m_bIsInitialized);
- m_bShouldAbort = false;
-
int iIteration = 0;
// data projectors
@@ -290,7 +288,7 @@ void CSirtAlgorithm::run(int _iNrIterations)
// iteration loop
- for (; iIteration < _iNrIterations && !m_bShouldAbort; ++iIteration) {
+ for (; iIteration < _iNrIterations && !shouldAbort(); ++iIteration) {
// forward projection and difference calculation
pForwardProjector->project();