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.

68 lines
2.4 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: Queue.h
  3. //
  4. // Copyright (c) 1999-2000, Microsoft Corporation
  5. //
  6. // This file contains a class to handle a queue element and a class to handle
  7. // a queue of queue elements.
  8. //
  9. // History: 1999-11-07 vtan created
  10. // 2000-08-25 vtan moved from Neptune to Whistler
  11. // --------------------------------------------------------------------------
  12. #ifndef _Queue_
  13. #define _Queue_
  14. #include "DynamicObject.h"
  15. #include "KernelResources.h"
  16. // --------------------------------------------------------------------------
  17. // CQueueElement
  18. //
  19. // Purpose: This is the queue element base class. It contains a field
  20. // which the queue manages.
  21. //
  22. // History: 1999-11-07 vtan created
  23. // 2000-08-25 vtan moved from Neptune to Whistler
  24. // --------------------------------------------------------------------------
  25. class CQueueElement : public CDynamicObject
  26. {
  27. private:
  28. friend class CQueue;
  29. public:
  30. CQueueElement (void);
  31. virtual ~CQueueElement (void);
  32. private:
  33. CQueueElement* _pNextElement;
  34. };
  35. // --------------------------------------------------------------------------
  36. // CQueue
  37. //
  38. // Purpose: This is the queue manager class. It manages queue elements.
  39. // Because the queue may be called from two threads that act on
  40. // the same object (one thread reads the queue to process
  41. // requests and the other adds to the queue to queue requests)
  42. // a critical section is required to process queue manipulation.
  43. //
  44. // History: 1999-11-07 vtan created
  45. // 2000-08-25 vtan moved from Neptune to Whistler
  46. // --------------------------------------------------------------------------
  47. class CQueue
  48. {
  49. public:
  50. CQueue (void);
  51. ~CQueue (void);
  52. void Add (CQueueElement *pQueueElement);
  53. void Remove (void);
  54. CQueueElement* Get (void) const;
  55. private:
  56. CQueueElement* _pQueue;
  57. CCriticalSection _lock;
  58. };
  59. #endif /* _Queue_ */