-void *processEventBuffer(void *arg)
-{
- //
- // event procssing thread functio
- //
-
- //cast argument
- AliTPCCalibCE *ce=(AliTPCCalibCE*)arg;
- AliTPCCalibCE &calibCE=*ce;
-
- size_t counter=0;
- unsigned long32 runNb=0;
- Bool_t published=kTRUE;
- struct timespec duree_out;
-
- struct eventHeaderStruct *event;
-
- //wait for the first buffer to be filled
- while (!eventBuffer[0]) nanosleep(&duree_nanosleep,&duree_out);
- //loop over buffer
- while (!bStop){
-// printf("testing buffer: %d\n",counter);
- if (eventBuffer[counter]) {
- event=eventBuffer[counter];
- runNb = event->eventRunNb;
-// printf("processing buffer: %d\n",counter);
- eventBuffer[counter]=0;
- calibCE.ProcessEvent(event);
- free(event);
- published=kFALSE;
- } else {
- //in case of empty buffer publish the results it this was not done
- if (!published) {
- SendToAmoreDB(calibCE,runNb);
- published=kTRUE;
- }
- nanosleep(&duree_nanosleep,&duree_out);
- }
- ++counter;
- if (counter >= eventBuffer.size()) {
- counter=0;
- if (forceBufferEnds) break;
- }
- }
-}