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.

162 lines
4.4 KiB

  1. //+------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997 - 1998.
  5. //
  6. // File: abortwid.cxx
  7. //
  8. // Contents: Tracks aborted wids that are not refiled
  9. //
  10. // Classes: CAbortedWids
  11. //
  12. // History: 24-Feb-97 SitaramR Created
  13. //
  14. // Notes: The data structure is a sequential array of aborted
  15. // wids. In push filtering, the number of aborted wids
  16. // should be small and hence the choice of sequential
  17. // array.
  18. //
  19. //-------------------------------------------------------------------
  20. #include <pch.cxx>
  21. #pragma hdrstop
  22. #include "abortwid.hxx"
  23. //+---------------------------------------------------------------------------
  24. //
  25. // Member: CAbortedWids::CAbortedWids
  26. //
  27. // Synopsis: Constructor
  28. //
  29. // History: 24-Feb-97 SitaramR Created
  30. //
  31. //----------------------------------------------------------------------------
  32. CAbortedWids::CAbortedWids()
  33. : _aAbortedWids( 0 )
  34. {
  35. }
  36. //+-------------------------------------------------------------------------
  37. //
  38. // Method: CAbortedWids::NoFailLokAddWid
  39. //
  40. // Synopsis: Adds wid to the aborted list
  41. //
  42. // Arguments: [wid] -- Workid to be added
  43. // [usn] -- USN of the notification
  44. //
  45. // History: 24-Feb-1997 SitaramR Created
  46. //
  47. //--------------------------------------------------------------------------
  48. void CAbortedWids::NoFailLokAddWid( WORKID wid, USN usn )
  49. {
  50. Win4Assert( wid != widInvalid );
  51. Win4Assert( usn > 0 );
  52. // Space for the wid was pre-allocated in Reserve(), since we can't
  53. // afford to take an exception here.
  54. Win4Assert( _aAbortedWids.Count() < _aAbortedWids.Size() );
  55. CAbortedWidEntry widEntry( wid, usn );
  56. _aAbortedWids.Add( widEntry, _aAbortedWids.Count() );
  57. } //NoFailLokAddWid
  58. //+-------------------------------------------------------------------------
  59. //
  60. // Method: CAbortedWids::LokRemoveWid
  61. //
  62. // Synopsis: Adds wid to the aborted list
  63. //
  64. // Arguments: [wid] -- Workid to be added
  65. // [usn] -- USN of the notification
  66. //
  67. // History: 24-Feb-1997 SitaramR Created
  68. //
  69. //--------------------------------------------------------------------------
  70. void CAbortedWids::LokRemoveWid( WORKID wid, USN usn )
  71. {
  72. Win4Assert( wid != widInvalid );
  73. Win4Assert( usn > 0 );
  74. unsigned count = _aAbortedWids.Count();
  75. for ( unsigned i=0; i<_aAbortedWids.Count(); i++ )
  76. {
  77. if ( _aAbortedWids.Get(i)._wid == wid &&
  78. _aAbortedWids.Get(i)._usn == usn )
  79. {
  80. _aAbortedWids.Remove(i);
  81. break;
  82. }
  83. }
  84. //
  85. // Check that the wid was found in the array. We
  86. // are using count, instead of _aAbortedWids.Count()
  87. // because the latter will decrease after the Remove().
  88. //
  89. Win4Assert( i < count );
  90. } //LokRemoveWid
  91. //+-------------------------------------------------------------------------
  92. //
  93. // Method: CAbortedWids::LokIsWidAborted
  94. //
  95. // Synopsis: Adds wid to the aborted list
  96. //
  97. // Arguments: [wid] -- Workid to be added
  98. // [usn] -- USN of the notification
  99. //
  100. // History: 24-Feb-1997 SitaramR Created
  101. //
  102. //--------------------------------------------------------------------------
  103. BOOL CAbortedWids::LokIsWidAborted( WORKID wid, USN usn )
  104. {
  105. Win4Assert( wid != widInvalid );
  106. //
  107. // Can be called in pull filtering where usn's can be zero, hence
  108. // no assertion on value of usn
  109. //
  110. CAbortedWidEntry widEntry( wid, usn );
  111. for ( unsigned i=0; i<_aAbortedWids.Count(); i++ )
  112. {
  113. if ( _aAbortedWids.Get(i)._wid == wid &&
  114. _aAbortedWids.Get(i)._usn == usn )
  115. {
  116. return TRUE;
  117. }
  118. }
  119. return FALSE;
  120. } //LokIsWidAborted
  121. //+-------------------------------------------------------------------------
  122. //
  123. // Method: CAbortedWids::LokReserve
  124. //
  125. // Synopsis: Reserve space for potentially aborted wids.
  126. //
  127. // Arguments: [cWids] -- # of slots to reserve now for failure later
  128. //
  129. // History: 27-April-1998 dlee Created
  130. //
  131. //--------------------------------------------------------------------------
  132. void CAbortedWids::LokReserve( unsigned cWids )
  133. {
  134. unsigned cPossible = _aAbortedWids.Count() + cWids;
  135. if ( _aAbortedWids.Size() < cPossible )
  136. _aAbortedWids.SetSize( cPossible );
  137. } //LokReserve