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.

152 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1998-2000 Microsoft Corporation
  3. Module Name:
  4. w32dispq.h
  5. Abstract:
  6. Contains the Win32 Operation Dispatch Object class,
  7. W32DispatchQueue.
  8. Author:
  9. Tad Brockway (tadb) 4/19/99
  10. Revision History:
  11. --*/
  12. #ifndef __W32DISPQ_H__
  13. #define __W32DISPQ_H__
  14. #include "drobject.h"
  15. #include "drqueue.h"
  16. typedef (*W32DispatchQueueFunc)(PVOID clientData, BOOL cancelled);
  17. ///////////////////////////////////////////////////////////////
  18. //
  19. // W32DispatchQueue
  20. //
  21. // Asynchronously dispatch operations.
  22. //
  23. //
  24. class W32DispatchQueue : public DrObject {
  25. private:
  26. typedef struct _QUEUEELEMENT {
  27. W32DispatchQueueFunc func;
  28. VOID *clientData;
  29. } QUEUEELEMENT, *PQUEUEELEMENT;
  30. //
  31. // The queue.
  32. //
  33. DrQueue<QUEUEELEMENT> *_queue;
  34. //
  35. // Synchronize data-ready in the queue.
  36. //
  37. HANDLE _dataReadyEvent;
  38. public:
  39. //
  40. // Constructor/Destructor
  41. //
  42. W32DispatchQueue();
  43. ~W32DispatchQueue();
  44. ///
  45. // Initialize
  46. //
  47. DWORD Initialize();
  48. //
  49. // Peek at the next entry in the queue without dequeueing.
  50. //
  51. BOOL PeekNextEntry(W32DispatchQueueFunc *func=NULL,
  52. VOID **clientData=NULL);
  53. //
  54. // Grab the next queued operation out of the queue.
  55. //
  56. BOOL Dequeue(W32DispatchQueueFunc *func=NULL,
  57. VOID **clientData=NULL);
  58. //
  59. // Add an element to the queue in FIFO fashion.
  60. //
  61. BOOL Enqueue(W32DispatchQueueFunc func,
  62. VOID *clientData=NULL);
  63. //
  64. // Requeue an element at the tail of the queue in LIFO fashion.
  65. //
  66. BOOL Requeue(W32DispatchQueueFunc func,
  67. VOID *clientData=NULL,
  68. BOOL signalNewData = FALSE);
  69. //
  70. // Get access to a waitable object that can be waited on for
  71. // data-ready in the queue.
  72. //
  73. HANDLE GetWaitableObject() {
  74. return _dataReadyEvent;
  75. }
  76. //
  77. // Returns the number of elements in the queue.
  78. //
  79. ULONG GetCount() {
  80. return _queue->GetCount();
  81. }
  82. //
  83. // Lock/Unlock the queue.
  84. //
  85. VOID Lock() {
  86. _queue->Lock();
  87. }
  88. VOID Unlock() {
  89. _queue->Unlock();
  90. }
  91. //
  92. // Return the class name.
  93. //
  94. virtual DRSTRING ClassName() { return TEXT("W32DispatchQueue"); }
  95. };
  96. #endif