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.

56 lines
1.6 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation
  4. //
  5. // SYNOPSIS
  6. //
  7. // Declares the class Perimeter
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef PERIMETER_H
  11. #define PERIMETER_H
  12. #pragma once
  13. ///////////////////////////////////////////////////////////////////////////////
  14. //
  15. // CLASS
  16. //
  17. // Perimeter
  18. //
  19. // DESCRIPTION
  20. //
  21. // This class implements a Perimeter synchronization object. Threads
  22. // may request either exclusive or shared access to the protected area.
  23. //
  24. ///////////////////////////////////////////////////////////////////////////////
  25. class Perimeter
  26. {
  27. public:
  28. Perimeter() throw ();
  29. ~Perimeter() throw ();
  30. HRESULT FinalConstruct() throw ();
  31. void Lock() throw ();
  32. void LockExclusive() throw ();
  33. void Unlock() throw ();
  34. protected:
  35. LONG sharing; // Number of threads sharing the perimiter.
  36. LONG waiting; // Number of threads waiting for shared access.
  37. PLONG count; // Pointer to either sharing or waiting depending
  38. // on the current state of the perimiter.
  39. bool exclusiveInitialized;
  40. CRITICAL_SECTION exclusive; // Synchronizes exclusive access.
  41. HANDLE sharedOK; // Wakes up threads waiting for shared.
  42. HANDLE exclusiveOK; // Wakes up threads waiting for exclusive.
  43. private:
  44. // Not implemented.
  45. Perimeter(const Perimeter&) throw ();
  46. Perimeter& operator=(const Perimeter&) throw ();
  47. };
  48. #endif // PERIMETER_H