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.

92 lines
2.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: E V E N T Q . H
  7. //
  8. // Contents: Event Queue for managing synchonization of external events.
  9. //
  10. // Notes:
  11. //
  12. // Author: ckotze 29 Nov 2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include "nmbase.h"
  17. #include <ncstl.h>
  18. #include <queue>
  19. using namespace std;
  20. class CEvent
  21. {
  22. public:
  23. CEvent(IN HANDLE hEvent) throw();
  24. ~CEvent() throw();
  25. HRESULT SetEvent();
  26. HRESULT ResetEvent();
  27. private:
  28. HANDLE m_hEvent;
  29. BOOL m_bSignaled;
  30. };
  31. enum EVENT_MANAGER;
  32. typedef DWORD (WINAPI CONMAN_EVENTTHREAD)(
  33. IN TAKEOWNERSHIP CONMAN_EVENT* lpEvent
  34. );
  35. typedef CONMAN_EVENTTHREAD *PCONMAN_EVENTTHREAD;
  36. typedef struct tagUSERWORKITEM
  37. {
  38. PCONMAN_EVENTTHREAD Function;
  39. CONMAN_EVENT* Event;
  40. EVENT_MANAGER EventMgr;
  41. } USERWORKITEM;
  42. typedef list<USERWORKITEM> EVENTQUEUE;
  43. typedef EVENTQUEUE::iterator EVENTQUEUEITER;
  44. class CEventQueue
  45. {
  46. public:
  47. CEventQueue(HANDLE hServiceShutdown) throw (HRESULT);
  48. ~CEventQueue() throw();
  49. HRESULT EnqueueEvent(IN PCONMAN_EVENTTHREAD Function,
  50. IN TAKEOWNERSHIP CONMAN_EVENT* pEvent,
  51. IN const EVENT_MANAGER EventMgr);
  52. HRESULT DequeueEvent(OUT PCONMAN_EVENTTHREAD& Function,
  53. OUT TAKEOWNERSHIP CONMAN_EVENT*& pEvent,
  54. OUT EVENT_MANAGER& EventMgr);
  55. BOOL AtomCheckSizeAndResetEvent(IN const BOOL fDispatchEvents) throw();
  56. DWORD WaitForExit() throw();
  57. size_t size() throw();
  58. private:
  59. EVENTQUEUE m_eqWorkItems;
  60. CRITICAL_SECTION m_csQueue;
  61. CEvent* m_pFireEvents;
  62. HANDLE m_hServiceShutdown;
  63. HANDLE m_hWait;
  64. BOOL m_fRefreshAllInQueue;
  65. };
  66. BOOL
  67. QueueUserWorkItemInThread(
  68. IN PCONMAN_EVENTTHREAD Function,
  69. IN TAKEOWNERSHIP CONMAN_EVENT* Context,
  70. IN EVENT_MANAGER EventMgr) throw();
  71. CONMAN_EVENTTHREAD ConmanEventWorkItem;
  72. CONMAN_EVENTTHREAD RasEventWorkItem;
  73. CONMAN_EVENTTHREAD LanEventWorkItem;
  74. CONMAN_EVENTTHREAD IncomingEventWorkItem;