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.

59 lines
797 B

  1. /*++
  2. Copyright (c) 1998-2002 Microsoft Corporation
  3. Module Name :
  4. _locks.h
  5. Abstract:
  6. Internal locks header file
  7. Author:
  8. George V. Reilly (GeorgeRe) 06-Jan-1998
  9. Environment:
  10. Win32 - User Mode
  11. Project:
  12. LKRhash
  13. Revision History:
  14. --*/
  15. #define LOCKS_SWITCH_TO_THREAD
  16. extern "C" {
  17. BOOL
  18. Locks_Initialize();
  19. BOOL
  20. Locks_Cleanup();
  21. }; // extern "C"
  22. class CSimpleLock
  23. {
  24. public:
  25. CSimpleLock()
  26. : m_l(0)
  27. {}
  28. void Enter()
  29. {
  30. while (Lock_AtomicExchange(const_cast<LONG*>(&m_l), 1) != 0)
  31. Sleep(0);
  32. }
  33. void Leave()
  34. {
  35. Lock_AtomicExchange(const_cast<LONG*>(&m_l), 0);
  36. }
  37. volatile LONG m_l;
  38. };