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.

62 lines
1.7 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
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. basicLogCollection *m_pLog;
  12. #if defined( __linux__ ) || defined(WIN_PTHREAD)
  13. pthread_t m_sThreadAHandler;
  14. static void *m_fThreadAEntryPoint(void *);
  15. pthread_t m_sThreadBHandler;
  16. static void *m_fThreadBEntryPoint(void *);
  17. #else
  18. HANDLE m_hThreadAHandle;
  19. HANDLE m_hThreadBHandle;
  20. DWORD m_dwThreadAID;
  21. DWORD m_dwThreadBID;
  22. static DWORD WINAPI m_fThreadAEntryPoint( LPVOID lpParameter );
  23. static DWORD WINAPI m_fThreadBEntryPoint( LPVOID lpParameter );
  24. #endif
  25. protected:
  26. thredStatus m_bThreadAStatus;
  27. virtual void m_fThreadAProc( void );
  28. thredStatus m_bThreadBStatus;
  29. virtual void m_fThreadBProc( void );
  30. public:
  31. // Constructor
  32. basicDualThread();
  33. // Destructor
  34. ~basicDualThread();
  35. virtual bool init( void );
  36. virtual bool uninit( void );
  37. thredStatus getAStatus( void ){ return m_bThreadAStatus; };
  38. thredStatus getBStatus(void){ return m_bThreadBStatus; };
  39. void waitThreadAEnd( bool Force = true );
  40. void waitThreadBEnd( bool Force = true );
  41. };
  42. // Constructor implementation
  43. inline basicDualThread::basicDualThread(){
  44. m_pLog = basicLogCollection::getInstance();
  45. m_bThreadAStatus = TH_PRE_INIT;
  46. m_bThreadBStatus = TH_PRE_INIT;
  47. };
  48. // Destructor implementation
  49. inline basicDualThread::~basicDualThread(){
  50. waitThreadAEnd( true );
  51. waitThreadBEnd( true );
  52. };
  53. #endif // __BASICTHREAD_H_INCL__