Skip to content

Commit bb6e7aa

Browse files
committed
MAINT: convert writetofile
1 parent 96f03e3 commit bb6e7aa

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

applications/mne_scan/plugins/writetofile/writetofile.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ WriteToFile::WriteToFile()
111111

112112
WriteToFile::~WriteToFile()
113113
{
114-
if(this->isRunning()) {
114+
if(m_bProcessOutput) {
115115
stop();
116116
}
117117
}
@@ -145,7 +145,8 @@ void WriteToFile::unload()
145145

146146
bool 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

155156
bool 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

applications/mne_scan/plugins/writetofile/writetofile.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
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

0 commit comments

Comments
 (0)