mtcore.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #include "stdafx.h"
  11. #ifdef _DEBUG
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. #define new DEBUG_NEW
  16. /////////////////////////////////////////////////////////////////////////////
  17. // Basic synchronization object
  18. CSyncObject::CSyncObject(LPCTSTR pstrName)
  19. {
  20. UNUSED(pstrName); // unused in release builds
  21. m_hObject = NULL;
  22. #ifdef _DEBUG
  23. m_strName = pstrName;
  24. #endif
  25. }
  26. CSyncObject::~CSyncObject()
  27. {
  28. if (m_hObject != NULL)
  29. {
  30. ::CloseHandle(m_hObject);
  31. m_hObject = NULL;
  32. }
  33. }
  34. BOOL CSyncObject::Lock(DWORD dwTimeout)
  35. {
  36. if (::WaitForSingleObject(m_hObject, dwTimeout) == WAIT_OBJECT_0)
  37. return TRUE;
  38. else
  39. return FALSE;
  40. }
  41. #ifdef _DEBUG
  42. void CSyncObject::Dump(CDumpContext& dc) const
  43. {
  44. dc << "Object ";
  45. dc << m_hObject;
  46. dc << " named " << m_strName << "\n";
  47. CObject::Dump(dc);
  48. }
  49. void CSyncObject::AssertValid() const
  50. {
  51. CObject::AssertValid();
  52. }
  53. #endif
  54. //////////////////////////////////////////////////////////////////////////////
  55. // Inline function declarations expanded out-of-line
  56. #ifndef _AFX_ENABLE_INLINES
  57. static char _szAfxMtInl[] = "afxmt.inl";
  58. #undef THIS_FILE
  59. #define THIS_FILE _szAfxMtInl
  60. #define _AFXMT_INLINE
  61. #include "afxmt.inl"
  62. #endif
  63. #ifdef AFX_INIT_SEG
  64. #pragma code_seg(AFX_INIT_SEG)
  65. #endif
  66. IMPLEMENT_DYNAMIC(CCriticalSection, CSyncObject)
  67. IMPLEMENT_DYNAMIC(CSyncObject, CObject)
  68. /////////////////////////////////////////////////////////////////////////////