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.

106 lines
1.6 KiB

  1. //=================================================================
  2. //
  3. // TimeOutRule.cpp
  4. //
  5. // Copyright (c) 1999-2001 Microsoft Corporation, All Rights Reserved
  6. //
  7. //=================================================================
  8. #include "precomp.h"
  9. #include "ResourceManager.h"
  10. #include "TimerQueue.h"
  11. #include "TimeOutRule.h"
  12. CTimeOutRule :: CTimeOutRule (
  13. DWORD dwTimeOut,
  14. CResource *pResource,
  15. CResourceList *pResources
  16. ) : CRule ( pResource ) ,
  17. CTimerEvent ( dwTimeOut , FALSE )
  18. {
  19. m_pResources = pResources ;
  20. m_bTimeOut = FALSE ;
  21. this->Enable () ;
  22. }
  23. CTimeOutRule :: ~CTimeOutRule ()
  24. {
  25. }
  26. void CTimeOutRule :: Detach ()
  27. {
  28. CRule :: Detach () ;
  29. Disable () ;
  30. }
  31. BOOL CTimeOutRule :: CheckRule ()
  32. {
  33. if ( m_bTimeOut )
  34. {
  35. m_bTimeOut = FALSE ;
  36. return TRUE ;
  37. }
  38. else
  39. {
  40. return FALSE ;
  41. }
  42. }
  43. void CTimeOutRule :: OnTimer ()
  44. {
  45. CRule::AddRef () ;
  46. try
  47. {
  48. if ( m_pResource )
  49. {
  50. /*
  51. * check if the cache manager is being unloaded
  52. */
  53. if ( ! m_pResources->m_bShutDown )
  54. {
  55. /*
  56. * wait for a lock on res. list
  57. */
  58. CResourceListAutoLock cs ( m_pResources ) ;
  59. /*
  60. * check if the cache manager is being unloaded
  61. */
  62. if ( ! m_pResources->m_bShutDown )
  63. {
  64. if ( m_pResource )
  65. {
  66. m_bTimeOut = TRUE ;
  67. m_pResource->RuleEvaluated ( this ) ;
  68. }
  69. }
  70. }
  71. }
  72. }
  73. catch( ... )
  74. {
  75. CRule::Release () ;
  76. throw ;
  77. }
  78. CRule::Release () ;
  79. }
  80. ULONG CTimeOutRule :: AddRef ()
  81. {
  82. return CRule::AddRef () ;
  83. }
  84. ULONG CTimeOutRule :: Release ()
  85. {
  86. return CRule::Release () ;
  87. }