replaced usleep which waits for queue to have data, with semaphores

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@732 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d
2014-02-06 14:54:01 +00:00
parent f5413637c4
commit 83405b70c8
4 changed files with 16 additions and 3 deletions

View File

@ -35,7 +35,9 @@ postProcessing::postProcessing(): expTime(NULL), ang(NULL), val(NULL), err(NULL)
pCallbackArg = 0;
//cout << "done "<< endl;
rawDataReady = 0;
pRawDataArg = 0;
pRawDataArg = 0;
sem_init(&queue_mutex,0,0);
#ifdef VERBOSE
registerDataCallback(&defaultDataReadyFunc, NULL);
@ -581,6 +583,7 @@ int* postProcessing::popDataQueue() {
cout << "Pop data queue lock" << endl;
#endif
sem_wait(&queue_mutex);
pthread_mutex_lock(&mp);
if( !dataQueue.empty() ) {
retval=dataQueue.front();
@ -609,6 +612,7 @@ void postProcessing::resetDataQueue() {
int *retval=NULL;
pthread_mutex_lock(&mp);
while( !dataQueue.empty() ) {
sem_wait(&queue_mutex);
retval=dataQueue.front();
dataQueue.pop();
delete [] retval;