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.

60 lines
979 B

  1. ////
  2. // DbgCrit.cpp
  3. // ~~~~~~~~~~~
  4. //
  5. // This file holds the critical section class for tracking down whether the
  6. // critical section has correctly left within the routine.
  7. #include "pch.h"
  8. #if DEBUG
  9. SZTHISFILE
  10. //////
  11. // CCritSec::CCritSec
  12. //
  13. // The constructor calls EnterCriticalSection and sets up the variables
  14. //
  15. CCritSec::CCritSec
  16. (
  17. CRITICAL_SECTION *CritSec
  18. )
  19. {
  20. EnterCriticalSection(CritSec);
  21. m_fLeft = FALSE;
  22. m_pCriticalSection = CritSec;
  23. } //CCritSec
  24. //////
  25. // CCritSec::~CCritSec
  26. //
  27. // The destructor checks the flag that tells us whether or not the
  28. // critical section was left properly or not.
  29. //
  30. CCritSec::~CCritSec
  31. (
  32. )
  33. {
  34. if(m_fLeft == FALSE)
  35. FAIL("CriticalSection was not left properly.");
  36. } //~CCritSec
  37. //////
  38. // CCritSec::Left
  39. //
  40. // A method that sets the flag to TRUE and also calls LeaveCriticalSection
  41. //
  42. void CCritSec::Left
  43. (
  44. void
  45. )
  46. {
  47. LeaveCriticalSection(m_pCriticalSection);
  48. m_fLeft = TRUE;
  49. } //Left
  50. #endif // DEBUG