File tree 2 files changed +14
-5
lines changed
applications/mne_scan/plugins/writetofile
2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ WriteToFile::WriteToFile()
111
111
112
112
WriteToFile::~WriteToFile ()
113
113
{
114
- if (this -> isRunning () ) {
114
+ if (m_bProcessOutput ) {
115
115
stop ();
116
116
}
117
117
}
@@ -145,7 +145,8 @@ void WriteToFile::unload()
145
145
146
146
bool WriteToFile::start ()
147
147
{
148
- QThread::start ();
148
+ m_bProcessOutput = true ;
149
+ m_OutputProcessingThread = std::thread (&WriteToFile::run, this );
149
150
150
151
return true ;
151
152
}
@@ -154,8 +155,11 @@ bool WriteToFile::start()
154
155
155
156
bool WriteToFile::stop ()
156
157
{
157
- requestInterruption ();
158
- wait ();
158
+ m_bProcessOutput = false ;
159
+
160
+ if (m_OutputProcessingThread.joinable ()){
161
+ m_OutputProcessingThread.join ();
162
+ }
159
163
160
164
m_bPluginControlWidgetsInit = false ;
161
165
@@ -293,7 +297,7 @@ void WriteToFile::run()
293
297
MatrixXd matData;
294
298
qint32 size = 0 ;
295
299
296
- while (! isInterruptionRequested () ) {
300
+ while (m_bProcessOutput ) {
297
301
if (m_pCircularBuffer) {
298
302
// pop matrix
299
303
Original file line number Diff line number Diff line change 46
46
#include < scShared/Plugins/abstractalgorithm.h>
47
47
#include < fiff/fifffilesharer.h>
48
48
49
+ #include < thread>
50
+
49
51
// =============================================================================================================
50
52
// QT INCLUDES
51
53
// =============================================================================================================
@@ -310,6 +312,9 @@ class WRITETOFILESHARED_EXPORT WriteToFile : public SCSHAREDLIB::AbstractAlgorit
310
312
FIFFLIB::FiffFileSharer m_FileSharer; /* *< Handles copying recording file and saving copy to shared directory. */
311
313
312
314
QStringList m_lFileNames; /* *< List of file names of latest recording */
315
+
316
+ std::thread m_OutputProcessingThread;
317
+ std::atomic_bool m_bProcessOutput;
313
318
};
314
319
} // NAMESPACE
315
320
You can’t perform that action at this time.
0 commit comments