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.

125 lines
3.5 KiB

  1. //+------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1991-1997 Microsoft Corporation.
  4. //
  5. // File: nottran.cxx
  6. //
  7. // Contents: Transaction object for notifications
  8. //
  9. // Classes: CNotificationTransaction
  10. //
  11. // History: 24-Feb-97 SitaramR Created
  12. //
  13. //-------------------------------------------------------------------
  14. #include <pch.cxx>
  15. #pragma hdrstop
  16. #include "notxact.hxx"
  17. #include "resman.hxx"
  18. //+---------------------------------------------------------------------------
  19. //
  20. // Member: CNotificationTransaction::CNotificationTransaction
  21. //
  22. // Synopsis: Constructor
  23. //
  24. // History: 24-Feb-97 SitaramR Created
  25. //
  26. // Notes: We initialize the array with a fairly size because we don't
  27. // want a grow to fail due to low memory during the changelog
  28. // transaction.
  29. //
  30. //----------------------------------------------------------------------------
  31. CNotificationTransaction::CNotificationTransaction( CResManager *pResManager,
  32. CIndexNotificationTable *pNotifTable )
  33. : _pResManager( pResManager ),
  34. _pNotifTable( pNotifTable ),
  35. _aCommittedWids(256),
  36. _aAbortedWidsToRemove(100)
  37. {
  38. }
  39. //+-------------------------------------------------------------------------
  40. //
  41. // Method: CNotificationTransactoin::~CNotificationTransaction
  42. //
  43. // Synopsis: Destructor
  44. //
  45. // History: 24-Feb-1997 SitaramR Created
  46. //
  47. //--------------------------------------------------------------------------
  48. CNotificationTransaction::~CNotificationTransaction()
  49. {
  50. if ( GetStatus() == CTransaction::XActCommit )
  51. {
  52. //
  53. // Commit the transaction which means commit the wids in the
  54. // comitted and remove the wids in the aborted list.
  55. //
  56. //
  57. // Commit outside resman lock to prevent a deadlock with the
  58. // lock in the notification table.
  59. //
  60. if ( _pNotifTable )
  61. _pNotifTable->CommitWids( _aCommittedWids );
  62. CLock lock( _pResManager->GetMutex() );
  63. for ( unsigned i=0; i<_aAbortedWidsToRemove.Count(); i++ )
  64. {
  65. _pResManager->LokRemoveAbortedWid( _aAbortedWidsToRemove.Get(i)._wid,
  66. _aAbortedWidsToRemove.Get(i)._usn );
  67. }
  68. }
  69. }
  70. //+-------------------------------------------------------------------------
  71. //
  72. // Method: CNotificationTransaction::AddCommittedWid
  73. //
  74. // Synopsis: Adds a wid to the commited list
  75. //
  76. // Arguments: [wid] -- WORKID
  77. //
  78. // History: 24-Feb-1997 SitaramR Created
  79. //
  80. //--------------------------------------------------------------------------
  81. void CNotificationTransaction::AddCommittedWid( WORKID wid )
  82. {
  83. Win4Assert( wid != widInvalid );
  84. _aCommittedWids.Add( wid, _aCommittedWids.Count() );
  85. }
  86. //+-------------------------------------------------------------------------
  87. //
  88. // Method: CNotificationTransaction::RemoveAbortedWid
  89. //
  90. // Synopsis: Adds a wid to the aborted-wids-to-remove list
  91. //
  92. // Arguments: [wid] -- WORKID
  93. // [usn] -- USN
  94. //
  95. // History: 24-Feb-1997 SitaramR Created
  96. //
  97. //--------------------------------------------------------------------------
  98. void CNotificationTransaction::RemoveAbortedWid( WORKID wid, USN usn )
  99. {
  100. Win4Assert( wid != widInvalid );
  101. Win4Assert( usn > 0 );
  102. CAbortedWidEntry widEntry( wid, usn );
  103. _aAbortedWidsToRemove.Add( widEntry, _aAbortedWidsToRemove.Count() );
  104. }