Leaked source code of windows server 2003
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.

81 lines
1.3 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997
  5. //
  6. // File: critsec.hxx
  7. //
  8. // Contents: Critical section Object
  9. //
  10. // History: 04-30-97 Sophiac Created.
  11. //
  12. //----------------------------------------------------------------------------
  13. #ifndef __WIN32_CRITSEC_HXX__
  14. #define __WIN32_CRITSEC_HXX__
  15. class WIN32_CRITSEC
  16. {
  17. CRITICAL_SECTION CriticalSection;
  18. public:
  19. inline WIN32_CRITSEC(
  20. );
  21. inline ~WIN32_CRITSEC(
  22. );
  23. void
  24. inline Enter(
  25. );
  26. void
  27. inline Leave(
  28. );
  29. };
  30. WIN32_CRITSEC::WIN32_CRITSEC(
  31. )
  32. {
  33. INITIALIZE_CRITICAL_SECTION(&CriticalSection);
  34. }
  35. WIN32_CRITSEC::~WIN32_CRITSEC(
  36. )
  37. {
  38. DeleteCriticalSection(&CriticalSection);
  39. }
  40. void
  41. WIN32_CRITSEC::Enter(
  42. )
  43. {
  44. EnterCriticalSection(&CriticalSection);
  45. }
  46. void
  47. WIN32_CRITSEC::Leave(
  48. )
  49. {
  50. LeaveCriticalSection(&CriticalSection);
  51. }
  52. extern WIN32_CRITSEC * g_pGlobalLock;
  53. class CLock
  54. {
  55. WIN32_CRITSEC * Critsec;
  56. public:
  57. CLock(WIN32_CRITSEC *pCritsec = g_pGlobalLock) : Critsec(pCritsec)
  58. {
  59. Critsec->Enter();
  60. }
  61. ~CLock()
  62. {
  63. Critsec->Leave();
  64. }
  65. };
  66. #endif