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.

39 lines
608 B

  1. #pragma once
  2. //
  3. // This is a generic class that wraps a given CComAutoCriticalSection
  4. //
  5. class CScopeCriticalSection
  6. {
  7. private:
  8. CComAutoCriticalSection* m_pCriticalSection;
  9. public:
  10. CScopeCriticalSection(CComAutoCriticalSection* pNewCS) :
  11. m_pCriticalSection(pNewCS)
  12. {
  13. Lock();
  14. }
  15. ~CScopeCriticalSection()
  16. {
  17. Unlock();
  18. }
  19. void
  20. inline Lock()
  21. {
  22. m_pCriticalSection->Lock();
  23. }
  24. void
  25. inline Unlock()
  26. {
  27. m_pCriticalSection->Unlock();
  28. }
  29. };
  30. #define ENTER_AUTO_CS CScopeCriticalSection _ScopeAutoCriticalSection(&m_AutoCS);