#include #include #include "thread.h" #define DATA_BUFSIZE 8192 #define MAX_THREAD_NUM 10 using namespace std; typedef unsigned int SOCKET; typedef struct{ SOCKET socket; char buffer[DATA_BUFSIZE]; int buffsize; } RECVBUFF; typedef list RECVBUFFLIST; class EpollHandler { class HandlerThread : public CThread //inside class { private: EpollHandler* m_pHandler; CSema* m_pSema; public: HandlerThread(EpollHandler* pHandler, CSema* pSema); virtual void Main(); }; private: RECVBUFFLIST m_lstBuff; HandlerThread* m_lstThreads[MAX_THREAD_NUM]; CSema m_smProcess; CSema m_smBuffers; public: EpollHandler(); ~EpollHandler(); void AddBuff(RECVBUFF*); RECVBUFF* GetBuff(); void Terminate(); }; class EpollThread : public CThread { private: EpollHandler* m_pHandler; int m_fdPipe[2]; bool SetNoBlock(int fd); public: EpollThread(); ~EpollThread(); virtual void Main(); virtual void Terminate(); };