Source code of Windows XP (NT5)
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.

106 lines
2.5 KiB

  1. //=============================================================================
  2. //
  3. // Copyright (c) 1996-1999, Microsoft Corporation, All rights reserved
  4. //
  5. // EQUEUE.CPP
  6. //
  7. // This file implements the classes for a queue of events which have matched
  8. // some of the filters and will have to be dispatched.
  9. //
  10. // See equeue.h for documentation
  11. //
  12. // History:
  13. //
  14. // 11/27/96 a-levn Compiles.
  15. //
  16. //=============================================================================
  17. #include "precomp.h"
  18. #include <stdio.h>
  19. #include "ess.h"
  20. #include "equeue.h"
  21. #include <cominit.h>
  22. #include "NCEvents.h"
  23. CEventQueue::CDeliverRequest::CDeliverRequest(CQueueingEventSink* pConsumer)
  24. : m_pConsumer(pConsumer)
  25. {
  26. m_pConsumer->AddRef();
  27. }
  28. CEventQueue::CDeliverRequest::~CDeliverRequest()
  29. {
  30. m_pConsumer->Release();
  31. }
  32. HRESULT CEventQueue::CDeliverRequest::Execute()
  33. {
  34. return m_pConsumer->DeliverAll();
  35. }
  36. //*****************************************************************************
  37. //************************ CEventQueue ****************************************
  38. //*****************************************************************************
  39. CEventQueue::CEventQueue(CEss* pEss) : m_pEss(pEss)
  40. {
  41. SetThreadLimits(100, 100, -1);
  42. m_dwTimeout = 60000;
  43. }
  44. void CEventQueue::InitializeThread()
  45. {
  46. //
  47. // Report the MSFT_WmiThreadPoolThreadCreated event.
  48. //
  49. FIRE_NCEVENT( g_hNCEvents[MSFT_WmiThreadPoolThreadCreated],
  50. WMI_SENDCOMMIT_SET_NOT_REQUIRED,
  51. GetCurrentThreadId());
  52. }
  53. void CEventQueue::UninitializeThread()
  54. {
  55. //
  56. // Report the MSFT_WmiThreadPoolThreadDeleted event.
  57. //
  58. FIRE_NCEVENT( g_hNCEvents[MSFT_WmiThreadPoolThreadDeleted],
  59. WMI_SENDCOMMIT_SET_NOT_REQUIRED,
  60. GetCurrentThreadId() );
  61. }
  62. void CEventQueue::ThreadMain(CThreadRecord* pRecord)
  63. {
  64. try
  65. {
  66. CExecQueue::ThreadMain(pRecord);
  67. }
  68. catch(...)
  69. {
  70. // Exit this thread gracefully
  71. // ===========================
  72. ShutdownThread(pRecord);
  73. }
  74. }
  75. HRESULT CEventQueue::EnqueueDeliver(CQueueingEventSink* pConsumer)
  76. {
  77. // Create a new request
  78. // ====================
  79. CDeliverRequest* pRequest = new CDeliverRequest(pConsumer);
  80. if(pRequest == NULL)
  81. return WBEM_E_OUT_OF_MEMORY;
  82. CExecQueue::Enqueue(pRequest);
  83. return S_OK;
  84. }
  85. void CEventQueue::DumpStatistics(FILE* f, long lFlags)
  86. {
  87. fprintf(f, "%d requests (%d threads) on the main queue\n", m_lNumRequests,
  88. m_lNumThreads);
  89. }