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.

89 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. mprlock.cxx
  5. Abstract:
  6. Contains code for the MPR provider database manager. This file
  7. contains the following classes:
  8. CMPRProviderLock
  9. Author:
  10. Jonathan Schwartz (jschwart) 19-May-1999
  11. Environment:
  12. User Mode -Win32
  13. Revision History:
  14. 19-May-1999 jschwart
  15. Created, converted from \nt\private\windows\screg\sc\server\lock.cxx.
  16. --*/
  17. //
  18. // INCLUDES
  19. //
  20. #include "precomp.hxx"
  21. //
  22. // Macros
  23. //
  24. #define LOCK_LOG(string) MPR_LOG3(LOCKS, " %s" string " level = %ld\n", \
  25. _ShortName, _Name, CurrentLevel())
  26. //
  27. // Globals
  28. //
  29. CProviderLock MPRProviderLock;
  30. /*************************************************************************/
  31. /* CCountingResource methods */
  32. /*************************************************************************/
  33. #if DBG
  34. void
  35. CCountingResource::GetShared()
  36. {
  37. LOCK_LOG(" Asking for %s lock shared...");
  38. ASSERT(!HaveExclusive());
  39. RtlAcquireResourceShared(&_Lock, TRUE);
  40. SetCurrentLevel(CurrentLevel() + 1);
  41. LOCK_LOG("+Acquired %s lock shared,");
  42. }
  43. void
  44. CCountingResource::GetExclusive()
  45. {
  46. LOCK_LOG(" Asking for %s lock exclusive...");
  47. ASSERT(!Have() || HaveExclusive());
  48. RtlAcquireResourceExclusive(&_Lock, TRUE);
  49. SetCurrentLevel(CurrentLevel() - 1);
  50. LOCK_LOG("+Acquired %s lock exclusive,");
  51. }
  52. void
  53. CCountingResource::Release()
  54. {
  55. LOCK_LOG("-Releasing %s lock...");
  56. ASSERT(Have());
  57. RtlReleaseResource( &_Lock );
  58. if (CurrentLevel() > 0)
  59. {
  60. SetCurrentLevel(CurrentLevel() - 1);
  61. }
  62. else
  63. {
  64. SetCurrentLevel(CurrentLevel() + 1);
  65. }
  66. LOCK_LOG(" Released %s lock,");
  67. }
  68. #endif // DBG