My Project
EPoll.h
1 #ifndef __EPoll_h__
2 #define __EPoll_h__
3 
4 #include "Log.h"
5 #include "Socket.h"
6 #include "Thread.h"
7 #include "TCPSession.h"
8 #include "Command.h"
9 
10 namespace core {
11 
30 
31  class EPoll : public Command {
32 
33  public:
34 
35  volatile long long eventId = 0;
36 
40 
41  EPoll();
42 
46 
47  ~EPoll();
48 
55 
56  bool start(int numberOfThreads, int maxSockets);
57 
63 
64  bool stop();
65 
70 
71  bool isStopping();
72 
81 
82  bool registerSocket(Socket *socket);
83 
87 
88  bool unregisterSocket(Socket *socket);
89 
93 
94  int getDescriptor();
95 
99 
101 
105 
106  void eventReceived(struct epoll_event event);
107 
114 
115  int processCommand(coreutils::ZString &request, TCPSession &session) override;
116 
117  void resetSocket(Socket *socket);
118 
119  private:
120 
121  int epfd;
122  int numberOfThreads;
123  std::vector<Thread> threads;
124  volatile bool terminateThreads;
125  void enableSocket(Socket *socket);
126  void disableSocket(Socket *socket);
127 
128  };
129 
130 }
131 
132 #endif
133 
Definition: Command.h:22
Definition: EPoll.h:31
bool stop()
Stop and shut down the BMAEPoll processing.
Definition: EPoll.cpp:46
int getDescriptor()
Return the descriptor for the ePoll socket.
Definition: EPoll.cpp:80
int processCommand(coreutils::ZString &request, TCPSession &session) override
Output the threads array to the console.
Definition: EPoll.cpp:84
EPoll()
Definition: EPoll.cpp:9
bool isStopping()
Returns a true if the stop command has been requested.
Definition: EPoll.cpp:66
void eventReceived(struct epoll_event event)
Dispatch event to appropriate socket.
bool registerSocket(Socket *socket)
Register a BMASocket for monitoring by BMAEPoll.
Definition: EPoll.cpp:70
bool unregisterSocket(Socket *socket)
Unregister a BMASocket from monitoring by BMAEPoll.
Definition: EPoll.cpp:75
~EPoll()
Definition: EPoll.cpp:18
bool start(int numberOfThreads, int maxSockets)
Start the BMAEPoll processing.
Definition: EPoll.cpp:20
int maxSockets
The maximum number of socket allowed.
Definition: EPoll.h:100
Definition: Socket.h:34
Definition: TCPSession.h:26