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.

53 lines
1.2 KiB

  1. //
  2. // MODULE: MutexOwner.cpp
  3. //
  4. // PURPOSE: strictly a utility class so we can properly construct & destruct a static mutex.
  5. //
  6. // COMPANY: Saltmine Creative, Inc. (206)-284-7511 [email protected]
  7. //
  8. // AUTHOR: Oleg Kalosha, Joe Mabel
  9. //
  10. // ORIGINAL DATE: 11-04-98
  11. //
  12. // NOTES:
  13. //
  14. // Version Date By Comments
  15. //--------------------------------------------------------------------
  16. // V3.0 11-04-98 JM extracted from SafeTime
  17. //
  18. #include "stdafx.h"
  19. #include "MutexOwner.h"
  20. #include "BaseException.h"
  21. #include "Event.h"
  22. //////////////////////////////////////////////////////////////////////
  23. //CMutexOwner
  24. //////////////////////////////////////////////////////////////////////
  25. CMutexOwner::CMutexOwner(const CString & str)
  26. {
  27. m_hmutex = ::CreateMutex(NULL, FALSE, NULL);
  28. if (!m_hmutex)
  29. {
  30. // Shouldn't ever happen, so we're not coming up with any elaborate strategy,
  31. // but at least we log it.
  32. CBuildSrcFileLinenoStr SrcLoc( __FILE__, __LINE__ );
  33. CEvent::ReportWFEvent( SrcLoc.GetSrcFileLineStr(),
  34. SrcLoc.GetSrcFileLineStr(),
  35. str,
  36. _T(""),
  37. EV_GTS_ERROR_MUTEX );
  38. }
  39. }
  40. CMutexOwner::~CMutexOwner()
  41. {
  42. ::CloseHandle(m_hmutex);
  43. }
  44. HANDLE & CMutexOwner::Handle()
  45. {
  46. return m_hmutex;
  47. }