Old fashion design for PC-104
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.

53 lines
1.4 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT: Laserguard libraries
  7. // SUBSYSTEM: LgLib
  8. // FILE: Thread.h
  9. // AUTHOR: Chizhevskiy Sergey
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of CThread
  13. //----------------------------------------------------------------------------
  14. #ifndef __THREAD__H__INCLUDED__
  15. #define __THREAD__H__INCLUDED__
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif
  19. class CLgThread
  20. {
  21. public:
  22. CLgThread();
  23. virtual ~CLgThread();
  24. public:
  25. virtual BOOL Start( BOOL bSelfDestroy );
  26. virtual BOOL Stop( BOOL bWaitForComplete );
  27. virtual BOOL IsStopping() { return m_hEventStopThread ? WaitForSingleObject( m_hEventStopThread, 0UL ) == WAIT_OBJECT_0 : FALSE; }
  28. virtual BOOL IsStopped() { return m_hThread == NULL; }
  29. public:
  30. virtual DWORD GetThreadId() { return m_dwThreadId; }
  31. virtual HANDLE GetThreadHandle() { return m_hThread; }
  32. virtual HANDLE GetThreadStopEvent() { return m_hEventStopThread; }
  33. protected:
  34. virtual DWORD ThreadProc() = 0;
  35. private:
  36. enum { MAX_THREAD_CLOSE_TIME = 10000UL };
  37. static UINT CALLBACK ThreadProc_( LPVOID );
  38. private:
  39. HANDLE m_hThread;
  40. DWORD m_dwThreadId;
  41. HANDLE m_hEventStopThread;
  42. BOOL m_bSelfDestroy;
  43. };
  44. #endif