BMA Server Framework
/home/barant/Development/BMA/server_core/ServerCore/BMAEPoll.h
1 #ifndef __BMAEPoll_h__
2 #define __BMAEPoll_h__
3 
4 #include "BMALog.h"
5 #include "BMASocket.h"
6 #include "BMAThread.h"
7 #include "BMASession.h"
8 #include "BMACommand.h"
9 
28 
29 class BMAEPoll : public BMACommand {
30 
31  public:
32 
36 
37  BMAEPoll();
38 
42 
43  ~BMAEPoll();
44 
51 
52  bool start(int numberOfThreads, int maxSockets);
53 
59 
60  bool stop();
61 
66 
67  bool isStopping();
68 
77 
78  bool registerSocket(BMASocket *socket);
79 
83 
84  bool unregisterSocket(BMASocket *socket);
85 
89 
90  int getDescriptor();
91 
95 
96  int maxSockets;
97 
101 
102  void eventReceived(struct epoll_event event);
103 
110 
111  void processCommand(std::string command, BMASession *session) override;
112 
113 private:
114 
115  int epfd;
116  int numberOfThreads;
117  std::map<int, BMASocket *> sockets;
118  std::vector<BMAThread> threads;
119  volatile bool terminateThreads;
120  std::mutex lock;
121 
122 };
123 
124 #endif
125 
int maxSockets
The maximum number of socket allowed.
Definition: BMAEPoll.h:96
Definition: BMASocket.h:31
void processCommand(std::string command, BMASession *session) override
Output the threads array to the console.
Definition: BMAEPoll.cpp:112
int getDescriptor()
Return the descriptor for the ePoll socket.
Definition: BMAEPoll.cpp:108
BMAEPoll()
Definition: BMAEPoll.cpp:7
Definition: BMAEPoll.h:29
bool unregisterSocket(BMASocket *socket)
Unregister a BMASocket from monitoring by BMAEPoll.
Definition: BMAEPoll.cpp:83
bool registerSocket(BMASocket *socket)
Register a BMASocket for monitoring by BMAEPoll.
Definition: BMAEPoll.cpp:70
bool start(int numberOfThreads, int maxSockets)
Start the BMAEPoll processing.
Definition: BMAEPoll.cpp:20
Definition: BMACommand.h:8
void eventReceived(struct epoll_event event)
Dispatch event to appropriate socket.
Definition: BMAEPoll.cpp:96
bool isStopping()
Returns a true if the stop command has been requested.
Definition: BMAEPoll.cpp:66
bool stop()
Stop and shut down the BMAEPoll processing.
Definition: BMAEPoll.cpp:46
Definition: BMASession.h:18
~BMAEPoll()
Definition: BMAEPoll.cpp:16