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.

67 lines
1.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1999.
  5. //
  6. // File: W R L O C K . H
  7. //
  8. // Contents: Defines the interface to the netcfg write lock used to
  9. // protect the network configuration information from being
  10. // modified by more than one writer at a time.
  11. //
  12. // Notes:
  13. //
  14. // Author: shaunco 15 Jan 1999
  15. //
  16. //----------------------------------------------------------------------------
  17. #pragma once
  18. // This is the interface to the write lock that INetCfg uses.
  19. //
  20. class CWriteLock
  21. {
  22. private:
  23. HANDLE m_hMutex;
  24. BOOL m_fOwned;
  25. private:
  26. HRESULT
  27. HrEnsureMutexCreated ();
  28. VOID
  29. SetOrQueryLockHolder (
  30. IN BOOL fSet,
  31. IN PCWSTR pszNewOwnerDesc,
  32. OUT PWSTR* ppszCurrentOwnerDesc);
  33. public:
  34. CWriteLock ()
  35. {
  36. m_hMutex = NULL;
  37. m_fOwned = FALSE;
  38. }
  39. ~CWriteLock ();
  40. BOOL
  41. WaitToAcquire (
  42. IN DWORD dwMilliseconds,
  43. IN PCWSTR pszNewOwnerDesc,
  44. OUT PWSTR* ppszCurrentOwnerDesc);
  45. BOOL
  46. FIsLockedByAnyone (
  47. OUT PWSTR* ppszCurrentOwnerDesc OPTIONAL);
  48. BOOL
  49. FIsOwnedByMe ()
  50. {
  51. AssertH (FImplies(m_fOwned, m_hMutex));
  52. return m_fOwned;
  53. }
  54. VOID
  55. ReleaseIfOwned ();
  56. };