Leaked source code of windows server 2003
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.

121 lines
2.3 KiB

  1. /*++
  2. Copyright (C) 1999-2001 Microsoft Corporation
  3. Module Name:
  4. ADAPTHRD.H
  5. Abstract:
  6. History:
  7. --*/
  8. #ifndef __ADAPTHRD_H__
  9. #define __ADAPTHRD_H__
  10. #include <wbemcomn.h>
  11. #include <sync.h>
  12. #include <execq.h>
  13. #include <wbemint.h>
  14. #include "adapelem.h"
  15. ///////////////////////////////////////////////////////////////////////////
  16. //
  17. // Forward Declarations
  18. //
  19. ///////////////////////////////////////////////////////////////////////////
  20. class CAdapPerfLib;
  21. ///////////////////////////////////////////////////////////////////////////
  22. //
  23. // CAdapThreadRequest
  24. //
  25. ///////////////////////////////////////////////////////////////////////////
  26. class CAdapThreadRequest : public CAdapElement
  27. {
  28. protected:
  29. HANDLE m_hWhenDone;
  30. HRESULT m_hrReturn;
  31. public:
  32. CAdapThreadRequest();
  33. virtual ~CAdapThreadRequest();
  34. void SetWhenDoneHandle(HANDLE h)
  35. {
  36. m_hWhenDone = h;
  37. }
  38. HANDLE GetWhenDoneHandle()
  39. {
  40. return m_hWhenDone;
  41. }
  42. HRESULT GetHRESULT( void )
  43. {
  44. return m_hrReturn;
  45. }
  46. virtual HRESULT Execute( CAdapPerfLib* pPerfLib ) = 0;
  47. virtual HRESULT EventLogError();
  48. };
  49. ///////////////////////////////////////////////////////////////////////////
  50. //
  51. // CAdapThread
  52. //
  53. ///////////////////////////////////////////////////////////////////////////
  54. class CAdapThread
  55. {
  56. private:
  57. CAdapPerfLib* m_pPerfLib; // The perflib being processed
  58. HANDLE m_hThreadReady; // The event to signal that the thread is ready
  59. HANDLE m_hThread; // The thread handle
  60. DWORD m_dwThreadId; // The thread ID
  61. HANDLE m_hEventQuit; // Thread termination event
  62. CFlexArray m_RequestQueue; // The queue
  63. HANDLE m_hSemReqPending; // The queue counter
  64. BOOL m_fOk; // Initialization flag
  65. CCritSec m_cs;
  66. static unsigned __stdcall ThreadProc( void * pVoid );
  67. unsigned RealEntry( void );
  68. protected:
  69. BOOL Init( void );
  70. virtual BOOL Clear( BOOL fClose = TRUE );
  71. HRESULT Begin( void );
  72. HRESULT Reset( void );
  73. public:
  74. CAdapThread( CAdapPerfLib* pPerfLib );
  75. virtual ~CAdapThread();
  76. // Assigns us work to do.
  77. HRESULT Enqueue( CAdapThreadRequest* pRequest );
  78. // Gently closes the thread
  79. HRESULT Shutdown( DWORD dwTimeout = 60000 );
  80. BOOL IsOk( void )
  81. {
  82. return m_fOk;
  83. }
  84. };
  85. #include "adapperf.h"
  86. #endif