]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MONITOR/AliThreadedSocket.h
Fix event server's preferences. Now, it reads them correctly from $ALICE_ROOT/MONITOR/
[u/mrichter/AliRoot.git] / MONITOR / AliThreadedSocket.h
CommitLineData
db352b46 1// Main authors: Mihai Niculescu 2014
2
3/**************************************************************************
4 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
5 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
6 * full copyright notice. *
7 **************************************************************************/
8
9#ifndef AliThreadedSocket_H
10#define AliThreadedSocket_H
11
12#include <TQObject.h>
13
14class TThread;
15class AliNetMessage;
16
17namespace zmq {
18 class context_t;
19}
20
21class AliThreadedSocket : public TQObject
22{
23public:
f05dd9ed 24 enum EOpenMode{kREAD, kWRITE};
db352b46 25
26 AliThreadedSocket(zmq::context_t *context, EOpenMode mode);
27 virtual ~AliThreadedSocket();
28
29 Bool_t Start();
30 Bool_t Stop();
31 Bool_t Kill();
f05dd9ed 32 void Wait();
db352b46 33
34 zmq::context_t* GetContext() const;
35 TThread* GetThread() const;
f05dd9ed 36 EOpenMode GetMode() const { return fOpenMode; }
db352b46 37
38 void Started(); // *SIGNAL*
39 void Stopped(); // *SIGNAL*
40
41 void Continue();
42
43protected:
44 AliThreadedSocket(const AliThreadedSocket&); // Not implemented
45 AliThreadedSocket& operator=(const AliThreadedSocket&); // Not implemented
46
f05dd9ed 47 // Reimplement these in a derived Class
48 virtual void RunThrdRead(); // function to run in a thread when in Read mode
49 virtual void RunThrdWrite(); // function to run in a thread when in Write mode
db352b46 50
db352b46 51 TThread* fThread;
f05dd9ed 52 zmq::context_t* fContext;
db352b46 53 EOpenMode fOpenMode;
54
f05dd9ed 55private:
56 static void* Dispatch(void* arg)
57 {
58 AliThreadedSocket* th = static_cast<AliThreadedSocket*>(arg);
59
60 if(th->GetMode()==kREAD)
61 th->RunThrdRead();
62 else
63 th->RunThrdWrite();
64
65 return NULL;
66 }
db352b46 67
68 ClassDef(AliThreadedSocket, 0);
db352b46 69};
70#endif