#include "TObjArray.h"
#include "TTimer.h"
#include "TThread.h"
+#include "TMutex.h"
#include "AliEveEventBuffer.h"
fTimer(NULL),
fEventId(),
fBufferMonStarted(kFALSE),
- fThread(NULL)
+ fThread(NULL),
+ fMutex(NULL)
{
// see header file for class documentation
fEventBuffer = new TObjArray(fBufferSize, 0);
}
fThread = new TThread(AliEveEventBuffer::BufferThread, (void*) this);
-
+ fMutex = new TMutex();
}
///___________________________________________________________________________
void AliEveEventBuffer::CreateBufferThread() {
+
+
cout << "Threadexists: " << fThread->Exists() << endl;
- if(GetBusy()) {
+ if( fMutex->TryLock() ) {
cout << "Buffer is busy, no thread created"<< endl;
-
+ return;
} else {
if ( (CalculateDifference(fBIndex[kTop],fBIndex[kLast]) < fPreBuffer) ) {
SetBusy(kTRUE);
///_____________________________________________________________________________
void AliEveEventBuffer::MonitorBuffer() {
cout << "Monitorbuffer() ";
- SetBusy(kTRUE);
FetchEvent();
- SetBusy(kFALSE);
+ fMutex->UnLock();
+
cout << "done " << endl;
}
if(!GetBufferMonStarted()) {
CreateBufferThread();
SetBufferMonStarted(kTRUE);
- fTimer->Start(10000);
+ fTimer->Start(15000);
} else {
cout << "Stopping buffer monitor"<<endl;
fTimer->Stop();