EventPool.h 656 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef __EVENTPOOL_H__
  2. #define __EVENTPOOL_H__
  3. #include "Lock.h"
  4. typedef struct _SEvent* LPSEVENT;
  5. class CEventThread;
  6. class CEventQueue;
  7. class CEventPool
  8. {
  9. CEventPool();
  10. public:
  11. static CEventPool* GetInstance()
  12. {
  13. static CEventPool obj;
  14. return &obj;
  15. }
  16. ~CEventPool();
  17. // 添加任务事件
  18. int AddEvent(IN LPSEVENT lpEvent);
  19. // 取出任务
  20. LPSEVENT TakeOutEvent();
  21. // 删除事件
  22. void DeleteEvent();
  23. // 清除所有事件
  24. void ClearAllEvent();
  25. // 获取事件数量
  26. int GetEventNum();
  27. // 终止线程
  28. void Terminate();
  29. private:
  30. CEventThread* m_pThread;
  31. CEventQueue* m_pEventQueue;
  32. DWORD m_dwEventSize;
  33. CLock m_lock;
  34. };
  35. #endif //__EVENTPOOL_H__