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.

176 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. dbgcs.hxx
  6. Abstract:
  7. Critical Section class header
  8. Author:
  9. Steve Kiraly (SteveKi) 30-March-1997
  10. Revision History:
  11. --*/
  12. #ifndef _DBGCS_HXX_
  13. #define _DBGCS_HXX_
  14. DEBUG_NS_BEGIN
  15. /********************************************************************
  16. Critical Section Class
  17. ********************************************************************/
  18. class TDebugCriticalSection
  19. {
  20. public:
  21. TDebugCriticalSection::
  22. TDebugCriticalSection(
  23. VOID
  24. );
  25. TDebugCriticalSection::
  26. ~TDebugCriticalSection(
  27. VOID
  28. );
  29. BOOL
  30. TDebugCriticalSection::
  31. bValid(
  32. VOID
  33. ) const;
  34. VOID
  35. TDebugCriticalSection::
  36. Enter(
  37. VOID
  38. );
  39. VOID
  40. TDebugCriticalSection::
  41. Leave(
  42. VOID
  43. );
  44. VOID
  45. TDebugCriticalSection::
  46. Initialize(
  47. VOID
  48. );
  49. VOID
  50. TDebugCriticalSection::
  51. Release(
  52. VOID
  53. );
  54. //
  55. // Helper class to enter and exit the critical section
  56. // using the constructor and destructor idiom.
  57. //
  58. class TLock
  59. {
  60. public:
  61. TLock::
  62. TLock(
  63. IN TDebugCriticalSection &CriticalSection
  64. );
  65. TLock::
  66. ~TLock(
  67. VOID
  68. );
  69. private:
  70. //
  71. // Copying and assignment are not defined.
  72. //
  73. TLock::
  74. TLock(
  75. const TLock &
  76. );
  77. TLock &
  78. TLock::
  79. operator =(
  80. const TLock &
  81. );
  82. TDebugCriticalSection &m_CriticalSection;
  83. };
  84. //
  85. // Helper class to exit and enter the critical section
  86. // using the constructor and destructor idiom.
  87. //
  88. class TUnLock
  89. {
  90. public:
  91. TUnLock::
  92. TUnLock(
  93. IN TDebugCriticalSection &CriticalSection
  94. );
  95. TUnLock::
  96. ~TUnLock(
  97. VOID
  98. );
  99. private:
  100. //
  101. // Copying and assignment are not defined.
  102. //
  103. TUnLock::
  104. TUnLock(
  105. const TUnLock &
  106. );
  107. TUnLock &
  108. TUnLock::
  109. operator =(
  110. const TUnLock &
  111. );
  112. TDebugCriticalSection &m_CriticalSection;
  113. };
  114. private:
  115. //
  116. // Copying and assignment are not defined.
  117. //
  118. TDebugCriticalSection::
  119. TDebugCriticalSection(
  120. const TDebugCriticalSection &
  121. );
  122. TDebugCriticalSection &
  123. TDebugCriticalSection::
  124. operator =(
  125. const TDebugCriticalSection &
  126. );
  127. CRITICAL_SECTION m_CriticalSection;
  128. BOOL m_bValid;
  129. };
  130. DEBUG_NS_END
  131. #endif