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.

69 lines
1.6 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 <stlqueue.h>
  19. using namespace std;
  20. class CEvent
  21. {
  22. public:
  23. CEvent(HANDLE hEvent);
  24. ~CEvent();
  25. HRESULT SetEvent();
  26. HRESULT ResetEvent();
  27. private:
  28. HANDLE m_hEvent;
  29. BOOL m_bSignaled;
  30. };
  31. enum EVENT_MANAGER;
  32. typedef struct tagUSERWORKITEM
  33. {
  34. LPTHREAD_START_ROUTINE Function;
  35. PVOID Event;
  36. EVENT_MANAGER EventMgr;
  37. } USERWORKITEM;
  38. typedef list<USERWORKITEM> EVENTQUEUE;
  39. typedef EVENTQUEUE::iterator EVENTQUEUEITER;
  40. class CEventQueue
  41. {
  42. public:
  43. CEventQueue(HANDLE hServiceShutdown);
  44. ~CEventQueue();
  45. HRESULT EnqueueEvent(IN LPTHREAD_START_ROUTINE Function, IN PVOID pEvent, IN const EVENT_MANAGER EventMgr);
  46. HRESULT DequeueEvent(OUT LPTHREAD_START_ROUTINE& Function, OUT PVOID& pEvent, OUT EVENT_MANAGER& EventMgr);
  47. BOOL AtomCheckSizeAndResetEvent(const BOOL fDispatchEvents);
  48. DWORD WaitForExit();
  49. size_t size();
  50. private:
  51. EVENTQUEUE m_eqWorkItems;
  52. CRITICAL_SECTION m_csQueue;
  53. CEvent* m_pFireEvents;
  54. HANDLE m_hServiceShutdown;
  55. HANDLE m_hWait;
  56. BOOL m_fRefreshAllInQueue;
  57. };