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.

88 lines
2.3 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. private:
  11. #if defined( __linux__ ) || defined(WIN_PTHREAD)
  12. pthread_t m_sThreadAHandler;
  13. static void *m_fThreadAEntryPoint(void *);
  14. pthread_t m_sThreadBHandler;
  15. static void *m_fThreadBEntryPoint(void *);
  16. #else
  17. HANDLE m_hThreadAHandle;
  18. HANDLE m_hThreadBHandle;
  19. DWORD m_dwThreadAID;
  20. DWORD m_dwThreadBID;
  21. static DWORD WINAPI m_fThreadAEntryPoint( LPVOID lpParameter );
  22. static DWORD WINAPI m_fThreadBEntryPoint( LPVOID lpParameter );
  23. #endif
  24. protected:
  25. thredStatus m_bThreadAStatus;
  26. virtual void m_fThreadAProc( void );
  27. thredStatus m_bThreadBStatus;
  28. virtual void m_fThreadBProc( void );
  29. basicLogCollection *m_pLog;
  30. public:
  31. // Constructor
  32. basicDualThread();
  33. // Destructor
  34. ~basicDualThread();
  35. virtual bool init( void );
  36. thredStatus getAStatus( void ){ return m_bThreadAStatus; };
  37. thredStatus getBStatus(void){ return m_bThreadBStatus; };
  38. void waitThreadAEnd( bool Force = true );
  39. void waitThreadBEnd( bool Force = true );
  40. };
  41. // Constructor implementation
  42. inline basicDualThread::basicDualThread(){
  43. m_pLog = basicLogCollection::getInstance();
  44. m_bThreadAStatus = TH_PRE_INIT;
  45. m_bThreadBStatus = TH_PRE_INIT;
  46. };
  47. // Destructor implementation
  48. inline basicDualThread::~basicDualThread(){
  49. if( m_bThreadAStatus > TH_ARMED ) {
  50. waitThreadAEnd();
  51. // Threads are detached inside Wait
  52. //pthread_detach( m_sThreadAHandler );
  53. };
  54. if( m_bThreadBStatus > TH_ARMED ) {
  55. waitThreadBEnd();
  56. //pthread_detach( m_sThreadBHandler );
  57. };
  58. };
  59. // TODO: Uncomment the copy constructor when you need it.
  60. //inline basicThread::basicThread(const basicThread& src)
  61. //{
  62. // // TODO: copy
  63. //}
  64. // TODO: Uncomment the assignment operator when you need it.
  65. //inline basicThread& basicThread::operator=(const basicThread& rhs)
  66. //{
  67. // if (this == &rhs) {
  68. // return *this;
  69. // }
  70. //
  71. // // TODO: assignment
  72. //
  73. // return *this;
  74. //}
  75. #endif // __BASICTHREAD_H_INCL__