class AliThreadedSocket : public TQObject
{
public:
- enum EOpenMode{READ, WRITE};
+ enum EOpenMode{kREAD, kWRITE};
AliThreadedSocket(zmq::context_t *context, EOpenMode mode);
virtual ~AliThreadedSocket();
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*
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