You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
1.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __BASICDUALTHREAD_H_INCL__
  2. #define __BASICDUALTHREAD_H_INCL__
  3. #include "basicThread.h"
  4. /**
  5. * TODO: Add class description
  6. *
  7. * @author Gagua
  8. */
  9. class basicDualThread
  10. {
  11. private:
  12. basicLogCollection * m_pLog;
  13. #if defined(__linux__) || defined(WIN_PTHREAD)
  14. pthread_t m_sThreadAHandler;
  15. static void * m_fThreadAEntryPoint(void *);
  16. pthread_t m_sThreadBHandler;
  17. static void * m_fThreadBEntryPoint(void *);
  18. #else
  19. HANDLE m_hThreadAHandle;
  20. HANDLE m_hThreadBHandle;
  21. DWORD m_dwThreadAID;
  22. DWORD m_dwThreadBID;
  23. static DWORD WINAPI m_fThreadAEntryPoint(LPVOID lpParameter);
  24. static DWORD WINAPI m_fThreadBEntryPoint(LPVOID lpParameter);
  25. #endif
  26. protected:
  27. thredStatus m_bThreadAStatus;
  28. virtual void m_fThreadAProc(void);
  29. thredStatus m_bThreadBStatus;
  30. virtual void m_fThreadBProc(void);
  31. public:
  32. // Constructor
  33. basicDualThread();
  34. // Destructor
  35. ~basicDualThread();
  36. virtual bool init(void);
  37. virtual bool uninit(void);
  38. thredStatus getAStatus(void)
  39. {
  40. return m_bThreadAStatus;
  41. }
  42. thredStatus getBStatus(void)
  43. {
  44. return m_bThreadBStatus;
  45. }
  46. void waitThreadAEnd(bool Force = true);
  47. void waitThreadBEnd(bool Force = true);
  48. };
  49. // Constructor implementation
  50. inline basicDualThread::basicDualThread()
  51. {
  52. m_pLog = basicLogCollection::getInstance();
  53. m_bThreadAStatus = TH_PRE_INIT;
  54. m_bThreadBStatus = TH_PRE_INIT;
  55. }
  56. // Destructor implementation
  57. inline basicDualThread::~basicDualThread()
  58. {
  59. waitThreadAEnd(true);
  60. waitThreadBEnd(true);
  61. }
  62. #endif // __BASICTHREAD_H_INCL__