]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MONITOR/AliThreadedSocket.h
Replace GetMass for M(), smearing for virtual photons added, histogramas for eta...
[u/mrichter/AliRoot.git] / MONITOR / AliThreadedSocket.h
index 677eb58f3b4a35884c6198333a2b40880bd4c5ab..c360f39b620950531c6fd876758b5fb0ade82c47 100644 (file)
@@ -21,7 +21,7 @@ namespace zmq {
 class AliThreadedSocket : public TQObject
 {
 public:
-       enum EOpenMode{READ, WRITE};
+       enum EOpenMode{kREAD, kWRITE};
 
        AliThreadedSocket(zmq::context_t *context, EOpenMode mode);
        virtual ~AliThreadedSocket();
@@ -29,9 +29,11 @@ public:
        Bool_t Start();
        Bool_t Stop();
        Bool_t Kill();
+       void Wait();
        
        zmq::context_t* GetContext() const;
        TThread* GetThread() const;
+       EOpenMode GetMode() const { return fOpenMode; }
                
        void Started(); // *SIGNAL*
        void Stopped(); // *SIGNAL*
@@ -42,16 +44,27 @@ protected:
   AliThreadedSocket(const AliThreadedSocket&);            // Not implemented
   AliThreadedSocket& operator=(const AliThreadedSocket&); // Not implemented
 
-       // reimplement these in a derived class
-       static void* RunThrdRead(void* arg);
-       static void* RunThrdWrite(void* arg);
+       // Reimplement these in a derived Class
+       virtual void RunThrdRead(); // function to run in a thread when in Read mode
+       virtual void RunThrdWrite(); // function to run in a thread when in Write mode
 
-       zmq::context_t* fContext;
        TThread* fThread;
+       zmq::context_t* fContext;
        EOpenMode fOpenMode;
 
+private:
+       static void* Dispatch(void* arg)
+       {
+               AliThreadedSocket* th = static_cast<AliThreadedSocket*>(arg);
+               
+               if(th->GetMode()==kREAD)
+                       th->RunThrdRead();
+               else
+                       th->RunThrdWrite();
+                       
+                       return NULL;
+       }
 
   ClassDef(AliThreadedSocket, 0);  
-
 };
 #endif