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

模拟服务器

开发平台:

C/C++

  1. //---------------------------------------------------------------------------
  2. // Sword3 Engine (c) 1999-2000 by Kingsoft
  3. //
  4. // File: KThread.h
  5. // Date: 2000.08.08
  6. // Code: WangWei(Daphnis)
  7. // Desc: Header File
  8. //---------------------------------------------------------------------------
  9. #ifndef KThread_H
  10. #define KThread_H
  11. //---------------------------------------------------------------------------
  12. typedef void (* TThreadFunc)(void* arg);
  13. #ifndef WIN32
  14. #include <pthread.h>
  15. #endif
  16. //---------------------------------------------------------------------------
  17. #ifdef WIN32
  18. class ENGINE_API KThread
  19. #else
  20. class KThread
  21. #endif
  22. {
  23. private:
  24. #ifdef WIN32
  25. HANDLE m_ThreadHandle;
  26. DWORD m_ThreadId;
  27. #else
  28.      pthread_t  p_thread;
  29. #endif
  30. TThreadFunc  m_ThreadFunc;
  31. LPVOID m_ThreadParam;
  32. public:
  33. KThread();
  34. ~KThread();
  35. BOOL Create(TThreadFunc lpFunc, void* lpParam);
  36. void Destroy();
  37. void Suspend();
  38. void Resume();
  39. BOOL IsRunning();
  40. void WaitForExit();
  41. int GetPriority();
  42. BOOL SetPriority(int priority);
  43. //private:
  44. DWORD ThreadFunction();
  45. #ifdef WIN32
  46. // static DWORD __stdcall ThreadProc(LPVOID lpParam);
  47. #else
  48. // void * ThreadProc(LPVOID lpParam);
  49. #endif
  50. };
  51. //---------------------------------------------------------------------------
  52. //---------------------------------------------------------------------------
  53. #endif