Thread.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:1k
源码类别:

模拟服务器

开发平台:

C/C++

  1. /********************************************************************
  2. created: 2003/02/14
  3. file base: Thread
  4. file ext: h
  5. author: liupeng
  6. purpose:
  7. *********************************************************************/
  8. #ifndef __INCLUDE_THREAD_H__
  9. #define __INCLUDE_THREAD_H__
  10. #if defined (_MSC_VER) && (_MSC_VER >= 1020)
  11. #pragma once
  12. #endif
  13. #ifndef _WINDOWS_
  14. #define WIN32_LEAN_AND_MEAN
  15. #include <windows.h>
  16. #undef WIN32_LEAN_AND_MEAN
  17. #endif
  18. /*
  19.  * namespace OnlineGameLib::Win32
  20.  */
  21. namespace OnlineGameLib {
  22. namespace Win32 {
  23. /*
  24.  * CThread
  25.  */
  26. class CThread 
  27. {
  28. public:
  29.    
  30. CThread();
  31.       
  32. virtual ~CThread();
  33. HANDLE GetHandle() const;
  34. void Wait() const;
  35. bool Wait(DWORD timeoutMillis) const;
  36. void Start();
  37. void Terminate( DWORD exitCode = 0 );
  38. private:
  39. virtual int Run() = 0;
  40. static unsigned int __stdcall ThreadFunction( void *pV );
  41. HANDLE m_hThread;
  42. /*
  43.  * No copies do not implement
  44.  */
  45. CThread( const CThread &rhs );
  46. CThread &operator=( const CThread &rhs );
  47. };
  48. } // End of namespace OnlineGameLib
  49. } // End of namespace Win32
  50. #endif //__INCLUDE_THREAD_H__