EPoll.h
Go to the documentation of this file.
#ifndef __EPoll_h__
#define __EPoll_h__
#include "Log.h"
#include "Socket.h"
#include "Thread.h"
#include "TCPSession.h"
#include "Command.h"
namespace core {
class EPoll : public Command {
public:
EPoll();
~EPoll();
bool start(int numberOfThreads, int maxSockets);
bool stop();
bool isStopping();
bool registerSocket(Socket *socket);
bool unregisterSocket(Socket *socket);
int getDescriptor();
int maxSockets;
void eventReceived(struct epoll_event event);
int processCommand(std::string command, TCPSession *session, std::stringstream &data) override;
void resetSocket(Socket *socket);
private:
int epfd;
int numberOfThreads;
std::vector<Thread> threads;
volatile bool terminateThreads;
void enableSocket(Socket *socket);
void disableSocket(Socket *socket);
};
}
#endif
core::EPoll
Definition: EPoll.h:31
core::EPoll::eventReceived
void eventReceived(struct epoll_event event)
Dispatch event to appropriate socket.
core::EPoll::resetSocket
void resetSocket(Socket *socket)
Definition: EPoll.cpp:110
core::EPoll::maxSockets
int maxSockets
The maximum number of socket allowed.
Definition: EPoll.h:98
core::EPoll::EPoll
EPoll()
Definition: EPoll.cpp:8
core::EPoll::unregisterSocket
bool unregisterSocket(Socket *socket)
Unregister a BMASocket from monitoring by BMAEPoll.
Definition: EPoll.cpp:77
TCPSession.h
core::TCPSession
Definition: TCPSession.h:25
core::Socket
Definition: Socket.h:33
core::EPoll::processCommand
int processCommand(std::string command, TCPSession *session, std::stringstream &data) override
Output the threads array to the console.
Definition: EPoll.cpp:87
core
Definition: Command.cpp:5
core::Command
Definition: Command.h:22
Thread.h
core::EPoll::~EPoll
~EPoll()
Definition: EPoll.cpp:17
core::EPoll::getDescriptor
int getDescriptor()
Return the descriptor for the ePoll socket.
Definition: EPoll.cpp:83
core::EPoll::registerSocket
bool registerSocket(Socket *socket)
Register a BMASocket for monitoring by BMAEPoll.
Definition: EPoll.cpp:71
core::EPoll::stop
bool stop()
Stop and shut down the BMAEPoll processing.
Definition: EPoll.cpp:47
Command.h
core::EPoll::isStopping
bool isStopping()
Returns a true if the stop command has been requested.
Definition: EPoll.cpp:67
Socket.h
core::EPoll::start
bool start(int numberOfThreads, int maxSockets)
Start the BMAEPoll processing.
Definition: EPoll.cpp:21