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.

57 lines
1.3 KiB

  1. //////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Lock.h
  4. //
  5. // Copyright (C) 1998, 1999 Microsoft Corporation. All rights reserved.
  6. //
  7. // Abstract :
  8. //
  9. // This is the definition of the CLock class. This class was created in order to
  10. // support automatic destruction of C++ object when an exception is thrown.
  11. //
  12. // Note :
  13. //
  14. // The CLock class is not thread safe (although the CCriticalSection class is). The CLock
  15. // class should be used as a local variable when locking using a CCriticalSection object.
  16. // This is done in order to warranty that all locks on an object are released when an
  17. // exception is thrown.
  18. //
  19. // History :
  20. //
  21. // 05/06/1999 luish Created
  22. //
  23. //////////////////////////////////////////////////////////////////////////////////////////////
  24. #if !defined(__LOCK_)
  25. #define __LOCK_
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. #include <windows.h>
  30. #include <objbase.h>
  31. #include "CriticalSection.h"
  32. class CLock
  33. {
  34. public :
  35. CLock(CCriticalSection * lpCriticalSection);
  36. ~CLock(void);
  37. STDMETHOD (Lock) (void);
  38. STDMETHOD (UnLock) (void);
  39. private :
  40. CCriticalSection * m_lpCriticalSection;
  41. DWORD m_dwBaseLockCount;
  42. DWORD m_dwLockCount;
  43. };
  44. #ifdef __cplusplus
  45. }
  46. #endif
  47. #endif // __LOCK_