GRUTinizer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TGRUTServer.h
Go to the documentation of this file.
1 #ifndef _TGRUTSERVER_H_
2 #define _TGRUTSERVER_H_
3 
4 #ifndef __CINT__
5  #include <atomic>
6  #include <memory>
7  #include <thread>
8 #endif
9 
10 #include <string>
11 
12 #include "TList.h"
13 #include "TMonitor.h"
14 #include "TObject.h"
15 #include "TServerSocket.h"
16 
17 
18 class TGRUTServer : public TObject {
19 public:
20  TGRUTServer(int port);
21  virtual ~TGRUTServer();
22 
23  void Start();
24  void Stop();
25 
26  int GetPort() { return port; }
27  void SetPort(int new_port);
28 
29 private:
30  TGRUTServer(const TGRUTServer&) { MayNotUse(__PRETTY_FUNCTION__); }
31  TGRUTServer& operator=(const TGRUTServer&) { MayNotUse(__PRETTY_FUNCTION__); }
32 
33  void Run();
34  void OpenPort();
35  void Iteration();
36  void DoNewConnection(TServerSocket*);
37  void DoRead(TSocket*);
38  void DoWrite(TSocket*);
39 
40  TMonitor *monitor;
41  TServerSocket *server;
42 
43  int port;
44  TList readlist;
45  TList writelist;
46 
47 #ifndef __CINT__
48  //std::unique_ptr<TServerSocket> server;
49  std::atomic_bool is_running;
50  std::chrono::milliseconds max_sleep;
51  std::thread listen_thread;
52 #endif
53 
55 };
56 
57 #endif /* _TGRUTSERVER_H_ */