File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
applications/mne_scan/plugins/writetofile Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ WriteToFile::WriteToFile()
111111
112112WriteToFile::~WriteToFile ()
113113{
114- if (this -> isRunning () ) {
114+ if (m_bProcessOutput ) {
115115 stop ();
116116 }
117117}
@@ -145,7 +145,8 @@ void WriteToFile::unload()
145145
146146bool WriteToFile::start ()
147147{
148- QThread::start ();
148+ m_bProcessOutput = true ;
149+ m_OutputProcessingThread = std::thread (&WriteToFile::run, this );
149150
150151 return true ;
151152}
@@ -154,8 +155,11 @@ bool WriteToFile::start()
154155
155156bool WriteToFile::stop ()
156157{
157- requestInterruption ();
158- wait ();
158+ m_bProcessOutput = false ;
159+
160+ if (m_OutputProcessingThread.joinable ()){
161+ m_OutputProcessingThread.join ();
162+ }
159163
160164 m_bPluginControlWidgetsInit = false ;
161165
@@ -293,7 +297,7 @@ void WriteToFile::run()
293297 MatrixXd matData;
294298 qint32 size = 0 ;
295299
296- while (! isInterruptionRequested () ) {
300+ while (m_bProcessOutput ) {
297301 if (m_pCircularBuffer) {
298302 // pop matrix
299303
Original file line number Diff line number Diff line change 4646#include < scShared/Plugins/abstractalgorithm.h>
4747#include < fiff/fifffilesharer.h>
4848
49+ #include < thread>
50+
4951// =============================================================================================================
5052// QT INCLUDES
5153// =============================================================================================================
@@ -310,6 +312,9 @@ class WRITETOFILESHARED_EXPORT WriteToFile : public SCSHAREDLIB::AbstractAlgorit
310312 FIFFLIB::FiffFileSharer m_FileSharer; /* *< Handles copying recording file and saving copy to shared directory. */
311313
312314 QStringList m_lFileNames; /* *< List of file names of latest recording */
315+
316+ std::thread m_OutputProcessingThread;
317+ std::atomic_bool m_bProcessOutput;
313318};
314319} // NAMESPACE
315320
You can’t perform that action at this time.
0 commit comments