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.

38 lines
572 B

  1. #ifndef PASSPORTLOCK_HPP
  2. #define PASSPORTLOCK_HPP
  3. #include <windows.h>
  4. #include <winbase.h>
  5. class PassportLock
  6. {
  7. public:
  8. PassportLock(DWORD dwSpinCount = 4000);
  9. void acquire();
  10. void release();
  11. ~PassportLock();
  12. private:
  13. CRITICAL_SECTION mLock;
  14. };
  15. class PassportLockGlobal
  16. {
  17. public:
  18. PassportLockGlobal(CRITICAL_SECTION &critSec)
  19. : mLock(critSec)
  20. {
  21. EnterCriticalSection(&mLock);
  22. }
  23. ~PassportLockGlobal()
  24. {
  25. LeaveCriticalSection(&mLock);
  26. }
  27. private:
  28. CRITICAL_SECTION &mLock;
  29. };
  30. #endif // !PASSPORTLOCK_HPP