File tree Expand file tree Collapse file tree 5 files changed +25
-9
lines changed
applications/mne_scan/plugins Expand file tree Collapse file tree 5 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,10 @@ bool Averaging::start()
118118bool Averaging::stop ()
119119{
120120 m_bProcessOutput = false ;
121- m_OutputProcessingThread.join ();
121+
122+ if (m_OutputProcessingThread.joinable ()){
123+ m_OutputProcessingThread.join ();
124+ }
122125
123126 m_bPluginControlWidgetsInit = false ;
124127
Original file line number Diff line number Diff line change @@ -168,8 +168,9 @@ bool Covariance::start()
168168
169169bool Covariance::stop ()
170170{
171+ m_bProcessOutput = false ;
172+
171173 if (m_OutputProcessingThread.joinable ()){
172- m_bProcessOutput = false ;
173174 m_OutputProcessingThread.join ();
174175 }
175176
Original file line number Diff line number Diff line change @@ -171,8 +171,9 @@ bool FiffSimulator::start()
171171bool FiffSimulator::stop ()
172172{
173173 // Stop this (consumer) thread first
174+ m_bProcessOutput = false ;
175+
174176 if (m_OutputProcessingThread.joinable ()){
175- m_bProcessOutput = false ;
176177 m_OutputProcessingThread.join ();
177178 }
178179
Original file line number Diff line number Diff line change @@ -105,8 +105,8 @@ Hpi::Hpi()
105105
106106Hpi::~Hpi ()
107107{
108- if (isRunning () ) {
109- resetState ();
108+ if (m_bProcessOutput ) {
109+ stop ();
110110 }
111111}
112112
@@ -144,7 +144,9 @@ void Hpi::unload()
144144
145145bool Hpi::start ()
146146{
147- QThread::start ();
147+ m_bProcessOutput = true ;
148+ m_OutputProcessingThread = std::thread (&Hpi::run, this );
149+
148150
149151 return true ;
150152}
@@ -153,7 +155,11 @@ bool Hpi::start()
153155
154156bool Hpi::stop ()
155157{
156- requestInterruption ();
158+ m_bProcessOutput = false ;
159+
160+ if (m_OutputProcessingThread.joinable ()){
161+ m_OutputProcessingThread.join ();
162+ }
157163 resetState ();
158164 return true ;
159165}
@@ -543,7 +549,7 @@ void Hpi::run()
543549 if (bFiffInfo) {
544550 break ;
545551 }
546- msleep ( 100 );
552+ std::this_thread::sleep_for ( std::chrono::milliseconds ( 100 ) );
547553 }
548554
549555 // init hpi fit
@@ -572,7 +578,7 @@ void Hpi::run()
572578
573579 MatrixXd matDataMerged (m_pFiffInfo->chs .size (), fittingWindowSize);
574580
575- while (! isInterruptionRequested () ) {
581+ while (m_bProcessOutput ) {
576582 m_mutex.lock ();
577583 if (fittingWindowSize != m_iFittingWindowSize) {
578584 fittingWindowSize = m_iFittingWindowSize;
Original file line number Diff line number Diff line change 4747
4848#include < fiff/fiff_dig_point.h>
4949
50+ #include < thread>
51+
5052// =============================================================================================================
5153// QT INCLUDES
5254// =============================================================================================================
@@ -320,6 +322,9 @@ class HPISHARED_EXPORT Hpi : public SCSHAREDLIB::AbstractAlgorithm
320322 SCSHAREDLIB::PluginInputData<SCMEASLIB::RealTimeMultiSampleArray>::SPtr m_pHpiInput; /* *< The RealTimeMultiSampleArray of the Hpi input.*/
321323 SCSHAREDLIB::PluginOutputData<SCMEASLIB::RealTimeHpiResult>::SPtr m_pHpiOutput; /* *< The RealTimeHpiResult of the Hpi output.*/
322324
325+ std::thread m_OutputProcessingThread;
326+ std::atomic_bool m_bProcessOutput;
327+
323328signals:
324329 void errorsChanged (const QVector<double >& vErrors,
325330 double dMeanErrorDist);
You can’t perform that action at this time.
0 commit comments