Skip to content

Commit

Permalink
MAINT: convert writetofile
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielbmotta committed Jan 26, 2022
1 parent 96f03e3 commit bb6e7aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 9 additions & 5 deletions applications/mne_scan/plugins/writetofile/writetofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ WriteToFile::WriteToFile()

WriteToFile::~WriteToFile()
{
if(this->isRunning()) {
if(m_bProcessOutput) {
stop();
}
}
Expand Down Expand Up @@ -145,7 +145,8 @@ void WriteToFile::unload()

bool WriteToFile::start()
{
QThread::start();
m_bProcessOutput = true;
m_OutputProcessingThread = std::thread(&WriteToFile::run, this);

return true;
}
Expand All @@ -154,8 +155,11 @@ bool WriteToFile::start()

bool WriteToFile::stop()
{
requestInterruption();
wait();
m_bProcessOutput = false;

if(m_OutputProcessingThread.joinable()){
m_OutputProcessingThread.join();
}

m_bPluginControlWidgetsInit = false;

Expand Down Expand Up @@ -293,7 +297,7 @@ void WriteToFile::run()
MatrixXd matData;
qint32 size = 0;

while(!isInterruptionRequested()) {
while(m_bProcessOutput) {
if(m_pCircularBuffer) {
//pop matrix

Expand Down
5 changes: 5 additions & 0 deletions applications/mne_scan/plugins/writetofile/writetofile.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#include <scShared/Plugins/abstractalgorithm.h>
#include <fiff/fifffilesharer.h>

#include <thread>

//=============================================================================================================
// QT INCLUDES
//=============================================================================================================
Expand Down Expand Up @@ -310,6 +312,9 @@ class WRITETOFILESHARED_EXPORT WriteToFile : public SCSHAREDLIB::AbstractAlgorit
FIFFLIB::FiffFileSharer m_FileSharer; /**< Handles copying recording file and saving copy to shared directory. */

QStringList m_lFileNames; /**< List of file names of latest recording */

std::thread m_OutputProcessingThread;
std::atomic_bool m_bProcessOutput;
};
} // NAMESPACE

Expand Down

0 comments on commit bb6e7aa

Please sign in to comment.