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
1.6 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // Perimeter.h
  8. //
  9. // SYNOPSIS
  10. //
  11. // This file describes the class Perimeter.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 09/04/1997 Original version.
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #ifndef _PERIMETER_H_
  19. #define _PERIMETER_H_
  20. ///////////////////////////////////////////////////////////////////////////////
  21. //
  22. // CLASS
  23. //
  24. // Perimeter
  25. //
  26. // DESCRIPTION
  27. //
  28. // This class implements a Perimeter synchronization object. Threads
  29. // may request either exclusive or shared access to the protected area.
  30. //
  31. ///////////////////////////////////////////////////////////////////////////////
  32. class Perimeter
  33. {
  34. public:
  35. Perimeter() throw ();
  36. ~Perimeter() throw ();
  37. void Lock() throw ();
  38. void LockExclusive() throw ();
  39. void Unlock() throw ();
  40. protected:
  41. LONG sharing; // Number of threads sharing the perimiter.
  42. LONG waiting; // Number of threads waiting for shared access.
  43. PLONG count; // Pointer to either sharing or waiting depending
  44. // on the current state of the perimiter.
  45. CRITICAL_SECTION exclusive; // Synchronizes exclusive access.
  46. HANDLE sharedOK; // Wakes up threads waiting for shared.
  47. HANDLE exclusiveOK; // Wakes up threads waiting for exclusive.
  48. private:
  49. // Not implemented.
  50. Perimeter(const Perimeter&) throw ();
  51. Perimeter& operator=(const Perimeter&) throw ();
  52. };
  53. #endif // _PERIMETER_H_