File tree 4 files changed +16
-8
lines changed
applications/mne_scan/plugins
4 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ Averaging::Averaging()
85
85
86
86
Averaging::~Averaging ()
87
87
{
88
- if (m_OutputProcessingThread. joinable () )
88
+ if (m_bProcessOutput )
89
89
stop ();
90
90
}
91
91
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ Covariance::Covariance()
89
89
90
90
Covariance::~Covariance ()
91
91
{
92
- if (this -> isRunning () )
92
+ if (m_bProcessOutput )
93
93
stop ();
94
94
}
95
95
@@ -158,7 +158,8 @@ void Covariance::unload()
158
158
bool Covariance::start ()
159
159
{
160
160
// Start thread
161
- QThread::start ();
161
+ m_bProcessOutput = true ;
162
+ m_OutputProcessingThread = std::thread (&Covariance::run, this );
162
163
163
164
return true ;
164
165
}
@@ -167,8 +168,10 @@ bool Covariance::start()
167
168
168
169
bool Covariance::stop ()
169
170
{
170
- requestInterruption ();
171
- wait (500 );
171
+ if (m_OutputProcessingThread.joinable ()){
172
+ m_bProcessOutput = false ;
173
+ m_OutputProcessingThread.join ();
174
+ }
172
175
173
176
m_bPluginControlWidgetsInit = false ;
174
177
@@ -249,7 +252,7 @@ void Covariance::run()
249
252
break ;
250
253
}
251
254
m_mutex.unlock ();
252
- msleep ( 100 );
255
+ std::this_thread::sleep_for ( std::chrono::milliseconds ( 100 ) );
253
256
}
254
257
255
258
MatrixXd matData;
@@ -260,7 +263,7 @@ void Covariance::run()
260
263
RTPROCESSINGLIB::RtCov rtCov (m_pFiffInfo);
261
264
262
265
// Start processing data
263
- while (! isInterruptionRequested () ) {
266
+ while (m_bProcessOutput ) {
264
267
// Get the current data
265
268
if (m_pCircularBuffer->pop (matData)) {
266
269
m_mutex.lock ();
Original file line number Diff line number Diff line change 45
45
#include < scShared/Plugins/abstractalgorithm.h>
46
46
#include < utils/generics/circularbuffer.h>
47
47
48
+ #include < thread>
49
+
48
50
// =============================================================================================================
49
51
// EIGEN INCLUDES
50
52
// =============================================================================================================
@@ -164,6 +166,9 @@ class COVARIANCESHARED_EXPORT Covariance : public SCSHAREDLIB::AbstractAlgorithm
164
166
QSharedPointer<SCSHAREDLIB::PluginInputData<SCMEASLIB::RealTimeMultiSampleArray> > m_pCovarianceInput; /* *< The RealTimeMultiSampleArray of the Covariance input.*/
165
167
QSharedPointer<SCSHAREDLIB::PluginOutputData<SCMEASLIB::RealTimeCov> > m_pCovarianceOutput; /* *< The RealTimeCov of the Covariance output.*/
166
168
169
+ std::thread m_OutputProcessingThread;
170
+ std::atomic_bool m_bProcessOutput;
171
+
167
172
signals:
168
173
};
169
174
} // NAMESPACE
Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ FiffSimulator::FiffSimulator()
98
98
99
99
FiffSimulator::~FiffSimulator ()
100
100
{
101
- if (m_pFiffSimulatorProducer->isRunning () || m_OutputProcessingThread. joinable () ) {
101
+ if (m_pFiffSimulatorProducer->isRunning () || m_bProcessOutput ) {
102
102
stop ();
103
103
}
104
104
}
You can’t perform that action at this time.
0 commit comments