From b44039361d96f71dd1470fe3160ce3e79f90a2fc Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Wed, 17 Oct 2018 17:47:19 +0200 Subject: [PATCH] renamed joinThread getter setter --- .../multiSlsDetector/multiSlsDetector.cpp | 22 +++++++++---------- .../multiSlsDetector/multiSlsDetector.h | 6 ++--- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index ff4bd6df6..c4f73f39e 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -2880,12 +2880,11 @@ void multiSlsDetector::readFrameFromReceiver() { //wait for real time acquisition to start bool running = true; sem_wait(&sem_newRTAcquisition); - if (checkJoinThread()) + if (getJoinThreadFlag()) running = false; - //exit when checkJoinThread() (all sockets done) - while (running) { + while (running) { // reset data data = false; if (multiframe != NULL) @@ -3034,7 +3033,7 @@ void multiSlsDetector::readFrameFromReceiver() { // wait for next scan/measurement, else join thread sem_wait(&sem_newRTAcquisition); //done with complete acquisition - if (checkJoinThread()) + if (getJoinThreadFlag()) running = false; else { //starting a new scan/measurement (got dummy data) @@ -3678,7 +3677,7 @@ int multiSlsDetector::acquire(){ bool receiver = (setReceiverOnline()==ONLINE_FLAG); progressIndex=0; thisMultiDetector->stoppedFlag=0; - setJoinThread(0); + setJoinThreadFlag(false); int nm=thisMultiDetector->timerValue[MEASUREMENTS_NUMBER]; if (nm<1) @@ -3744,7 +3743,7 @@ int multiSlsDetector::acquire(){ }//end measurements loop im // waiting for the data processing thread to finish! - setJoinThread(1); + setJoinThreadFlag(true); sem_post(&sem_newRTAcquisition); dataProcessingThread.join(); @@ -3813,7 +3812,7 @@ void multiSlsDetector::processData() { setCurrentProgress(caught); } // exiting loop - if (checkJoinThread()){ + if (getJoinThreadFlag()){ break; } usleep(100 * 1000); //20ms need this else connecting error to receiver (too fast) @@ -3824,17 +3823,16 @@ void multiSlsDetector::processData() { } -int multiSlsDetector::checkJoinThread() { +bool multiSlsDetector::getJoinThreadFlag() { std::lock_guard lock(mp); return jointhread; } -void multiSlsDetector::setJoinThread( int v) { +void multiSlsDetector::setJoinThreadFlag( bool value) { std::lock_guard lock(mp); - jointhread=v; + jointhread=value; } - int multiSlsDetector::kbhit() { struct timeval tv; fd_set fds; @@ -3855,4 +3853,4 @@ bool multiSlsDetector::isDetectorIndexOutOfBounds(int detPos) { return true; } return false; -} +} \ No newline at end of file diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index daaedc3e5..df8a52591 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1666,13 +1666,13 @@ private: * Check if processing thread is ready to join main thread * @returns true if ready, else false */ - int checkJoinThread(); + bool getJoinThreadFlag(); /** * Main thread sets if the processing thread should join it * @param v true if it should join, else false */ - void setJoinThread(int v); + void setJoinThreadFlag(bool value); /** * Listen to key event to stop acquiring @@ -1719,7 +1719,7 @@ private: std::mutex mg; /** sets when the acquisition is finished */ - int jointhread; + bool jointhread; /** set when detector finishes acquiring */ int acquiringDone;