Check if busy before creating thread
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveEventBuffer.cxx
index e7817e414f4f0a698a79640cb45ef0bb0100f569..c94ec7ef8788a6325280bae4610f51bd404b46a9 100644 (file)
@@ -61,24 +61,24 @@ AliEveEventBuffer::~AliEveEventBuffer() {
   fCurrentEvent = NULL;
 
 }
+
 ///___________________________________________________________________________
 void AliEveEventBuffer::CreateBufferThread() {
-  cout << "CreateBufferThread()"<<endl;
-  TThread * fThread = new TThread(AliEveEventBuffer::BufferThread, (void*) this);
-  fThread->Run();
-  cout << "Done BufferThread"<<endl;
+  if(GetBusy()) {
+    cout << "Buffer is busy"<< endl;
+  } else {
+    cout << "CreateBufferThread()"<<endl;
+    TThread * fThread = new TThread(AliEveEventBuffer::BufferThread, (void*) this);
+    fThread->Run();
+    cout << "Done BufferThread"<<endl;
+  } 
 }
 
 ///___________________________________________________________________________
 void * AliEveEventBuffer::BufferThread(void * buffer) {
   cout <<"BufferThread : " <<endl;
   if(buffer) {
-    if (!reinterpret_cast<AliEveEventBuffer*>(buffer)->GetBusy()) {
       reinterpret_cast<AliEveEventBuffer*>(buffer)->MonitorBuffer();
-    } else {
-      cout << "busy"<<endl;
-    }
-    
   } else {
     cout << "no buffer"<<endl;
   }