File tree 5 files changed +25
-9
lines changed
applications/mne_scan/plugins
5 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,10 @@ bool Averaging::start()
118
118
bool Averaging::stop ()
119
119
{
120
120
m_bProcessOutput = false ;
121
- m_OutputProcessingThread.join ();
121
+
122
+ if (m_OutputProcessingThread.joinable ()){
123
+ m_OutputProcessingThread.join ();
124
+ }
122
125
123
126
m_bPluginControlWidgetsInit = false ;
124
127
Original file line number Diff line number Diff line change @@ -168,8 +168,9 @@ bool Covariance::start()
168
168
169
169
bool Covariance::stop ()
170
170
{
171
+ m_bProcessOutput = false ;
172
+
171
173
if (m_OutputProcessingThread.joinable ()){
172
- m_bProcessOutput = false ;
173
174
m_OutputProcessingThread.join ();
174
175
}
175
176
Original file line number Diff line number Diff line change @@ -171,8 +171,9 @@ bool FiffSimulator::start()
171
171
bool FiffSimulator::stop ()
172
172
{
173
173
// Stop this (consumer) thread first
174
+ m_bProcessOutput = false ;
175
+
174
176
if (m_OutputProcessingThread.joinable ()){
175
- m_bProcessOutput = false ;
176
177
m_OutputProcessingThread.join ();
177
178
}
178
179
Original file line number Diff line number Diff line change @@ -105,8 +105,8 @@ Hpi::Hpi()
105
105
106
106
Hpi::~Hpi ()
107
107
{
108
- if (isRunning () ) {
109
- resetState ();
108
+ if (m_bProcessOutput ) {
109
+ stop ();
110
110
}
111
111
}
112
112
@@ -144,7 +144,9 @@ void Hpi::unload()
144
144
145
145
bool Hpi::start ()
146
146
{
147
- QThread::start ();
147
+ m_bProcessOutput = true ;
148
+ m_OutputProcessingThread = std::thread (&Hpi::run, this );
149
+
148
150
149
151
return true ;
150
152
}
@@ -153,7 +155,11 @@ bool Hpi::start()
153
155
154
156
bool Hpi::stop ()
155
157
{
156
- requestInterruption ();
158
+ m_bProcessOutput = false ;
159
+
160
+ if (m_OutputProcessingThread.joinable ()){
161
+ m_OutputProcessingThread.join ();
162
+ }
157
163
resetState ();
158
164
return true ;
159
165
}
@@ -543,7 +549,7 @@ void Hpi::run()
543
549
if (bFiffInfo) {
544
550
break ;
545
551
}
546
- msleep ( 100 );
552
+ std::this_thread::sleep_for ( std::chrono::milliseconds ( 100 ) );
547
553
}
548
554
549
555
// init hpi fit
@@ -572,7 +578,7 @@ void Hpi::run()
572
578
573
579
MatrixXd matDataMerged (m_pFiffInfo->chs .size (), fittingWindowSize);
574
580
575
- while (! isInterruptionRequested () ) {
581
+ while (m_bProcessOutput ) {
576
582
m_mutex.lock ();
577
583
if (fittingWindowSize != m_iFittingWindowSize) {
578
584
fittingWindowSize = m_iFittingWindowSize;
Original file line number Diff line number Diff line change 47
47
48
48
#include < fiff/fiff_dig_point.h>
49
49
50
+ #include < thread>
51
+
50
52
// =============================================================================================================
51
53
// QT INCLUDES
52
54
// =============================================================================================================
@@ -320,6 +322,9 @@ class HPISHARED_EXPORT Hpi : public SCSHAREDLIB::AbstractAlgorithm
320
322
SCSHAREDLIB::PluginInputData<SCMEASLIB::RealTimeMultiSampleArray>::SPtr m_pHpiInput; /* *< The RealTimeMultiSampleArray of the Hpi input.*/
321
323
SCSHAREDLIB::PluginOutputData<SCMEASLIB::RealTimeHpiResult>::SPtr m_pHpiOutput; /* *< The RealTimeHpiResult of the Hpi output.*/
322
324
325
+ std::thread m_OutputProcessingThread;
326
+ std::atomic_bool m_bProcessOutput;
327
+
323
328
signals:
324
329
void errorsChanged (const QVector<double >& vErrors,
325
330
double dMeanErrorDist);
You can’t perform that action at this time.
0 commit comments