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.

88 lines
2.1 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: mutex.hxx
  3. *
  4. * Defines some classes which make the use of semaphores more
  5. * convenient. These days, it has nothing to do with mutexes.
  6. *
  7. * Created: 29-Apr-1992 14:26:01
  8. * Author: Patrick Haluptzok patrickh
  9. *
  10. * Copyright (c) 1992-1999 Microsoft Corporation
  11. \**************************************************************************/
  12. #ifndef _MUTEX_HXX
  13. #define _MUTEX_HXX
  14. /*********************************class************************************\
  15. * class MLOCKFAST
  16. *
  17. * Semaphore used to protect the handle manager.
  18. *
  19. * History:
  20. * 28-May-1992 -by- Patrick Haluptzok patrickh
  21. * Wrote it.
  22. \**************************************************************************/
  23. class MLOCKFAST
  24. {
  25. public:
  26. MLOCKFAST()
  27. {
  28. GreAcquireHmgrSemaphore();
  29. }
  30. ~MLOCKFAST()
  31. {
  32. GreReleaseHmgrSemaphore();
  33. }
  34. };
  35. /*********************************class************************************\
  36. * class MLOCKOBJ
  37. *
  38. * Semaphore used to protect the handle manager. Much like MLOCKFAST.
  39. *
  40. * History:
  41. * Wed 29-Apr-1992 -by- Patrick Haluptzok [patrickh]
  42. * Re-Wrote it.
  43. *
  44. * Mon 11-Mar-1991 16:41:00 -by- Donald Sidoroff [donalds]
  45. * Wrote it.
  46. \**************************************************************************/
  47. class MLOCKOBJ
  48. {
  49. private:
  50. BOOL bActive; // Active/Inactive flag
  51. public:
  52. MLOCKOBJ() // Constructor
  53. {
  54. GreAcquireHmgrSemaphore();
  55. bActive = TRUE; // Activate the object
  56. }
  57. ~MLOCKOBJ()
  58. {
  59. if (bActive)
  60. {
  61. GreReleaseHmgrSemaphore();
  62. }
  63. }
  64. VOID vDisable()
  65. {
  66. ASSERTGDI(bActive, "Mutex was not claimed\n");
  67. GreReleaseHmgrSemaphore();
  68. bActive = FALSE;
  69. }
  70. VOID vLock() // lock the semaphore again.
  71. {
  72. GreAcquireHmgrSemaphore();
  73. bActive = TRUE; // Activate the object
  74. }
  75. };
  76. #endif // _MUTEX_HXX