semaphore just to check when it is over

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@734 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d
2014-02-06 17:25:18 +00:00
parent fcacc79f7b
commit 26c0520c10
3 changed files with 19 additions and 4 deletions

View File

@ -141,7 +141,9 @@ void slsDetectorUtils::acquire(int delflag){
} }
if (*threadedProcessing) { if (*threadedProcessing) {
sem_init(&sem_queue,0,0);
startThread(delflag); startThread(delflag);
} }
#ifdef VERBOSE #ifdef VERBOSE
@ -318,16 +320,21 @@ void slsDetectorUtils::acquire(int delflag){
if(setReceiverOnline()==OFFLINE_FLAG){ if(setReceiverOnline()==OFFLINE_FLAG){
pthread_mutex_lock(&mg); pthread_mutex_lock(&mg);
// wait until data processing thread has finished the data // wait until data processing thread has finished the data
acquiringDone = 1;
if (*threadedProcessing) {
sem_wait(&sem_queue);
acquiringDone = 0;
}
#ifdef VERBOSE #ifdef VERBOSE
cout << "check data queue size " << endl; cout << "check data queue size " << endl;
#endif #endif
while (dataQueueSize()){ /*while (dataQueueSize()){
#ifdef VERBOSE #ifdef VERBOSE
cout << "AAAAAAAAA check data queue size " << endl; cout << "AAAAAAAAA check data queue size " << endl;
#endif #endif
usleep(100000); usleep(100000);
} }*/
if ((getDetectorsType()==GOTTHARD) || (getDetectorsType()==MOENCH)){ if ((getDetectorsType()==GOTTHARD) || (getDetectorsType()==MOENCH)){
if((*correctionMask)&(1<<WRITE_FILE)) if((*correctionMask)&(1<<WRITE_FILE))
@ -463,6 +470,7 @@ void slsDetectorUtils::acquire(int delflag){
#endif #endif
setJoinThread(1); setJoinThread(1);
pthread_join(dataProcessingThread, &status); pthread_join(dataProcessingThread, &status);
sem_destroy(&sem_queue);
#ifdef VERBOSE #ifdef VERBOSE
cout << "data processing thread joined" << endl; cout << "data processing thread joined" << endl;
#endif #endif

View File

@ -37,7 +37,6 @@ postProcessing::postProcessing(): expTime(NULL), ang(NULL), val(NULL), err(NULL)
rawDataReady = 0; rawDataReady = 0;
pRawDataArg = 0; pRawDataArg = 0;
/* sem_init(&queue_mutex,0,0);*/
#ifdef VERBOSE #ifdef VERBOSE
registerDataCallback(&defaultDataReadyFunc, NULL); registerDataCallback(&defaultDataReadyFunc, NULL);
@ -407,6 +406,11 @@ void* postProcessing::processData(int delflag) {
} }
} }
/** IF detector acquisition is done, let the acquire() thread know to finish up and force join thread */
if(acquiringDone){
sem_post(&sem_queue);
}
/* IF THERE ARE NO DATA look if acquisition is finished */ /* IF THERE ARE NO DATA look if acquisition is finished */
if (checkJoinThread()) { if (checkJoinThread()) {
if (dataQueueSize()==0) { if (dataQueueSize()==0) {

View File

@ -296,7 +296,10 @@ s
int queuesize; int queuesize;
/** queue mutex */ /** queue mutex */
/*sem_t queue_mutex;*/ sem_t sem_queue;
/** set when detector finishes acquiring */
int acquiringDone;
/** /**