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.

165 lines
5.6 KiB

  1. #ifndef _LOCKS_HPP_
  2. #define _LOCKS_HPP_
  3. // Ruler
  4. // 1 2 3 4 5 6 7 8
  5. //345678901234567890123456789012345678901234567890123456789012345678901234567890
  6. /********************************************************************/
  7. /* */
  8. /* The standard layout. */
  9. /* */
  10. /* The standard layout for 'hpp' files for this code is as */
  11. /* follows: */
  12. /* */
  13. /* 1. Include files. */
  14. /* 2. Constants exported from the class. */
  15. /* 3. Data structures exported from the class. */
  16. /* 4. Forward references to other data structures. */
  17. /* 5. Class specifications (including inline functions). */
  18. /* 6. Additional large inline functions. */
  19. /* */
  20. /* Any portion that is not required is simply omitted. */
  21. /* */
  22. /********************************************************************/
  23. #include "Global.hpp"
  24. #include "Sharelock.hpp"
  25. #include "Spinlock.hpp"
  26. /********************************************************************/
  27. /* */
  28. /* Full lock structure. */
  29. /* */
  30. /* This class provides an full locking mechanism for a */
  31. /* collection of higher level classes. */
  32. /* */
  33. /********************************************************************/
  34. class FULL_LOCK
  35. {
  36. //
  37. // Private data.
  38. //
  39. SHARELOCK ShareLock;
  40. public:
  41. //
  42. // Public inline functions.
  43. //
  44. FULL_LOCK( VOID )
  45. { /* void */ }
  46. INLINE VOID ClaimExclusiveLock( VOID )
  47. { (VOID) ShareLock.ClaimExclusiveLock(); }
  48. INLINE VOID ClaimSharedLock( VOID )
  49. { (VOID) ShareLock.ClaimShareLock(); }
  50. INLINE VOID ReleaseExclusiveLock( VOID )
  51. { (VOID) ShareLock.ReleaseExclusiveLock(); }
  52. INLINE VOID ReleaseSharedLock( VOID )
  53. { (VOID) ShareLock.ReleaseShareLock(); }
  54. ~FULL_LOCK( VOID )
  55. { /* void */ }
  56. private:
  57. //
  58. // Disabled operations.
  59. //
  60. FULL_LOCK( CONST FULL_LOCK & Copy );
  61. VOID operator=( CONST FULL_LOCK & Copy );
  62. };
  63. /********************************************************************/
  64. /* */
  65. /* No lock structure. */
  66. /* */
  67. /* This class provides a default locking mechanism for a */
  68. /* collection of higher level classes. */
  69. /* */
  70. /********************************************************************/
  71. class NO_LOCK
  72. {
  73. public:
  74. //
  75. // Public inline functions.
  76. //
  77. NO_LOCK( VOID )
  78. { /* void */ }
  79. INLINE VOID ClaimExclusiveLock( VOID )
  80. { /* void */ }
  81. INLINE VOID ClaimSharedLock( VOID )
  82. { /* void */ }
  83. INLINE VOID ReleaseExclusiveLock( VOID )
  84. { /* void */ }
  85. INLINE VOID ReleaseSharedLock( VOID )
  86. { /* void */ }
  87. ~NO_LOCK( VOID )
  88. { /* void */ }
  89. private:
  90. //
  91. // Disabled operations.
  92. //
  93. NO_LOCK( CONST NO_LOCK & Copy );
  94. VOID operator=( CONST NO_LOCK & Copy );
  95. };
  96. /********************************************************************/
  97. /* */
  98. /* Partial lock structure. */
  99. /* */
  100. /* This class provides a partial locking mechanism for a */
  101. /* collection of higher level classes. */
  102. /* */
  103. /********************************************************************/
  104. class PARTIAL_LOCK
  105. {
  106. //
  107. // Private structures.
  108. //
  109. SPINLOCK Spinlock;
  110. public:
  111. //
  112. // Public inline functions.
  113. //
  114. PARTIAL_LOCK( VOID )
  115. { /* void */ }
  116. INLINE VOID ClaimExclusiveLock( VOID )
  117. { (VOID) Spinlock.ClaimLock(); }
  118. INLINE VOID ClaimSharedLock( VOID )
  119. { (VOID) Spinlock.ClaimLock(); }
  120. INLINE VOID ReleaseExclusiveLock( VOID )
  121. { (VOID) Spinlock.ReleaseLock(); }
  122. INLINE VOID ReleaseSharedLock( VOID )
  123. { (VOID) Spinlock.ReleaseLock(); }
  124. ~PARTIAL_LOCK( VOID )
  125. { /* void */ }
  126. private:
  127. //
  128. // Disabled operations.
  129. //
  130. PARTIAL_LOCK( CONST PARTIAL_LOCK & Copy );
  131. VOID operator=( CONST PARTIAL_LOCK & Copy );
  132. };
  133. #endif