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.

93 lines
2.1 KiB

  1. //==========================================================================
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright 1998 - 1999 Microsoft Corporation. All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------
  11. #include "precomp.h"
  12. //+---------------------------------------------------------------------------
  13. //
  14. // Member: CLockHandler::CLockHandler, public
  15. //
  16. // Synopsis: Constructor
  17. //
  18. // Arguments:
  19. //
  20. // Returns:
  21. //
  22. // Modifies:
  23. //
  24. //----------------------------------------------------------------------------
  25. CLockHandler::CLockHandler()
  26. {
  27. m_dwLockThreadId = 0;
  28. InitializeCriticalSection(&m_CriticalSection);
  29. }
  30. //+---------------------------------------------------------------------------
  31. //
  32. // Member: CLockHandler::~CLockHandler, public
  33. //
  34. // Synopsis: Destructor
  35. //
  36. // Arguments:
  37. //
  38. // Returns:
  39. //
  40. // Modifies:
  41. //
  42. //----------------------------------------------------------------------------
  43. CLockHandler::~CLockHandler()
  44. {
  45. Assert (0 == m_dwLockThreadId);
  46. DeleteCriticalSection(&m_CriticalSection);
  47. }
  48. //+---------------------------------------------------------------------------
  49. //
  50. // Member: CLockHandler::Lock, public
  51. //
  52. // Synopsis: Adds a lock to the specified class
  53. //
  54. // Arguments:
  55. //
  56. // Returns:
  57. //
  58. // Modifies:
  59. //
  60. //----------------------------------------------------------------------------
  61. void CLockHandler::Lock(DWORD dwThreadId)
  62. {
  63. EnterCriticalSection(&m_CriticalSection);
  64. m_dwLockThreadId = dwThreadId;
  65. }
  66. //+---------------------------------------------------------------------------
  67. //
  68. // Member: CLockHandler::UnLock, public
  69. //
  70. // Synopsis: Removes a lock to the specified class
  71. //
  72. // Arguments:
  73. //
  74. // Returns:
  75. //
  76. // Modifies:
  77. //
  78. //----------------------------------------------------------------------------
  79. void CLockHandler::UnLock()
  80. {
  81. m_dwLockThreadId = 0;
  82. LeaveCriticalSection(&m_CriticalSection);
  83. }