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.

38 lines
885 B

  1. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Microsoft WMI OLE DB Provider
  4. // (C) Copyright 1999 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // Generic class which encapsulates CCriticalSection class
  7. //
  8. //////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. #ifndef _AUTOBLOC_H_
  10. #define _AUTOBLOC_H_
  11. class CAutoBlock
  12. {
  13. private:
  14. CCriticalSection *m_pCriticalSection;
  15. public:
  16. CAutoBlock(CCriticalSection *pCriticalSection);
  17. ~CAutoBlock();
  18. };
  19. inline CAutoBlock::CAutoBlock(CCriticalSection *pCriticalSection)
  20. {
  21. m_pCriticalSection = NULL;
  22. if(pCriticalSection)
  23. pCriticalSection->Enter();
  24. m_pCriticalSection = pCriticalSection;
  25. }
  26. inline CAutoBlock::~CAutoBlock()
  27. {
  28. if(m_pCriticalSection)
  29. m_pCriticalSection->Leave();
  30. }
  31. #endif // _AUTOBLOC_H_