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.

156 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. priolist.hxx
  5. Abstract:
  6. Contains Prioritized serialized list class definitions
  7. Author:
  8. Richard L Firth (rfirth) 03-May-1997
  9. Revision History:
  10. 03-May-1997 rfirth
  11. Created
  12. --*/
  13. //
  14. // classes
  15. //
  16. //
  17. // CPriorityListEntry - prioritized list entry
  18. //
  19. class CPriorityListEntry {
  20. public:
  21. LIST_ENTRY m_ListEntry;
  22. private:
  23. LONG m_lPriority;
  24. public:
  25. CPriorityListEntry(LONG lPriority) {
  26. #if INET_DEBUG
  27. m_ListEntry.Flink = m_ListEntry.Blink = NULL;
  28. #endif
  29. m_lPriority = lPriority;
  30. }
  31. ~CPriorityListEntry() {
  32. INET_ASSERT((m_ListEntry.Flink == NULL)
  33. && (m_ListEntry.Blink == NULL));
  34. }
  35. PLIST_ENTRY List(VOID) {
  36. return &m_ListEntry;
  37. }
  38. PLIST_ENTRY Next(VOID) {
  39. return m_ListEntry.Flink;
  40. }
  41. PLIST_ENTRY Prev(VOID) {
  42. return m_ListEntry.Blink;
  43. }
  44. LONG GetPriority(VOID) const {
  45. return m_lPriority;
  46. }
  47. VOID SetPriority(LONG lPriority) {
  48. m_lPriority = lPriority;
  49. }
  50. VOID Remove(VOID) {
  51. RemoveEntryList(&m_ListEntry);
  52. #if INET_DEBUG
  53. m_ListEntry.Flink = m_ListEntry.Blink = NULL;
  54. #endif
  55. }
  56. };
  57. //
  58. // CPriorityList - maintains serialized list of CPriorityListEntry's
  59. //
  60. class CPriorityList {
  61. private:
  62. SERIALIZED_LIST m_List;
  63. public:
  64. CPriorityList() {
  65. InitializeSerializedList(&m_List);
  66. }
  67. ~CPriorityList() {
  68. TerminateSerializedList(&m_List);
  69. }
  70. LPSERIALIZED_LIST List(VOID) {
  71. return &m_List;
  72. }
  73. PLIST_ENTRY Self(VOID) {
  74. return (PLIST_ENTRY)&m_List.List.Flink;
  75. }
  76. PLIST_ENTRY Head(VOID) {
  77. return m_List.List.Flink;
  78. }
  79. VOID Acquire(VOID) {
  80. LockSerializedList(&m_List);
  81. }
  82. VOID Release(VOID) {
  83. UnlockSerializedList(&m_List);
  84. }
  85. BOOL IsEmpty(VOID) {
  86. return IsSerializedListEmpty(&m_List);
  87. }
  88. LONG Count(VOID) {
  89. return ElementsOnSerializedList(&m_List);
  90. }
  91. VOID
  92. Insert(
  93. IN CPriorityListEntry * pEntry,
  94. IN LONG lPriority
  95. ) {
  96. pEntry->SetPriority(lPriority);
  97. Insert(pEntry);
  98. }
  99. VOID
  100. Insert(
  101. IN CPriorityListEntry * pEntry
  102. );
  103. VOID
  104. Remove(
  105. IN CPriorityListEntry * pEntry
  106. );
  107. CPriorityListEntry * RemoveHead(VOID) {
  108. return (CPriorityListEntry * )SlDequeueHead(&m_List);
  109. }
  110. };