renamed joinThread getter setter

This commit is contained in:
Erik Frojdh 2018-10-17 17:47:19 +02:00
parent 0070a79838
commit b44039361d
2 changed files with 13 additions and 15 deletions

View File

@ -2880,12 +2880,11 @@ void multiSlsDetector::readFrameFromReceiver() {
//wait for real time acquisition to start //wait for real time acquisition to start
bool running = true; bool running = true;
sem_wait(&sem_newRTAcquisition); sem_wait(&sem_newRTAcquisition);
if (checkJoinThread()) if (getJoinThreadFlag())
running = false; running = false;
//exit when checkJoinThread() (all sockets done)
while (running) {
while (running) {
// reset data // reset data
data = false; data = false;
if (multiframe != NULL) if (multiframe != NULL)
@ -3034,7 +3033,7 @@ void multiSlsDetector::readFrameFromReceiver() {
// wait for next scan/measurement, else join thread // wait for next scan/measurement, else join thread
sem_wait(&sem_newRTAcquisition); sem_wait(&sem_newRTAcquisition);
//done with complete acquisition //done with complete acquisition
if (checkJoinThread()) if (getJoinThreadFlag())
running = false; running = false;
else { else {
//starting a new scan/measurement (got dummy data) //starting a new scan/measurement (got dummy data)
@ -3678,7 +3677,7 @@ int multiSlsDetector::acquire(){
bool receiver = (setReceiverOnline()==ONLINE_FLAG); bool receiver = (setReceiverOnline()==ONLINE_FLAG);
progressIndex=0; progressIndex=0;
thisMultiDetector->stoppedFlag=0; thisMultiDetector->stoppedFlag=0;
setJoinThread(0); setJoinThreadFlag(false);
int nm=thisMultiDetector->timerValue[MEASUREMENTS_NUMBER]; int nm=thisMultiDetector->timerValue[MEASUREMENTS_NUMBER];
if (nm<1) if (nm<1)
@ -3744,7 +3743,7 @@ int multiSlsDetector::acquire(){
}//end measurements loop im }//end measurements loop im
// waiting for the data processing thread to finish! // waiting for the data processing thread to finish!
setJoinThread(1); setJoinThreadFlag(true);
sem_post(&sem_newRTAcquisition); sem_post(&sem_newRTAcquisition);
dataProcessingThread.join(); dataProcessingThread.join();
@ -3813,7 +3812,7 @@ void multiSlsDetector::processData() {
setCurrentProgress(caught); setCurrentProgress(caught);
} }
// exiting loop // exiting loop
if (checkJoinThread()){ if (getJoinThreadFlag()){
break; break;
} }
usleep(100 * 1000); //20ms need this else connecting error to receiver (too fast) 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<std::mutex> lock(mp); std::lock_guard<std::mutex> lock(mp);
return jointhread; return jointhread;
} }
void multiSlsDetector::setJoinThread( int v) { void multiSlsDetector::setJoinThreadFlag( bool value) {
std::lock_guard<std::mutex> lock(mp); std::lock_guard<std::mutex> lock(mp);
jointhread=v; jointhread=value;
} }
int multiSlsDetector::kbhit() { int multiSlsDetector::kbhit() {
struct timeval tv; struct timeval tv;
fd_set fds; fd_set fds;

View File

@ -1666,13 +1666,13 @@ private:
* Check if processing thread is ready to join main thread * Check if processing thread is ready to join main thread
* @returns true if ready, else false * @returns true if ready, else false
*/ */
int checkJoinThread(); bool getJoinThreadFlag();
/** /**
* Main thread sets if the processing thread should join it * Main thread sets if the processing thread should join it
* @param v true if it should join, else false * @param v true if it should join, else false
*/ */
void setJoinThread(int v); void setJoinThreadFlag(bool value);
/** /**
* Listen to key event to stop acquiring * Listen to key event to stop acquiring
@ -1719,7 +1719,7 @@ private:
std::mutex mg; std::mutex mg;
/** sets when the acquisition is finished */ /** sets when the acquisition is finished */
int jointhread; bool jointhread;
/** set when detector finishes acquiring */ /** set when detector finishes acquiring */
int acquiringDone; int acquiringDone;