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.

54 lines
1.2 KiB

  1. #ifndef _GENCRITICALSECTION_H
  2. #define _GENCRITICALSECTION_H
  3. /////////////////////////////////////
  4. // This class doesn't do much now,
  5. // but this may help when we try to
  6. // optimize the Lock and Unlocks'
  7. /////////////////////////////////////
  8. typedef interface IGenCriticalSection
  9. {
  10. // Data members
  11. public:
  12. private:
  13. protected:
  14. CRITICAL_SECTION m_cs;
  15. // Methods
  16. public:
  17. IGenCriticalSection() { ::InitializeCriticalSection ( &m_cs ); }
  18. ~IGenCriticalSection() { ::DeleteCriticalSection ( &m_cs ); }
  19. virtual void ReadLock ( void ) = 0;
  20. virtual void ReadUnlock ( void ) = 0;
  21. virtual void WriteLock ( void ) = 0;
  22. virtual void WriteUnlock ( void ) = 0;
  23. private:
  24. protected:
  25. }IGenCriticalSection, *PGenCriticalSection, **PPGenCriticalSection;
  26. class CGenCriticalSection : public IGenCriticalSection
  27. {
  28. // Data members
  29. public:
  30. private:
  31. protected:
  32. // Methods
  33. public:
  34. private:
  35. protected:
  36. virtual void ReadLock ( void ) { ::EnterCriticalSection (&m_cs); };
  37. virtual void ReadUnlock ( void ) { ::LeaveCriticalSection (&m_cs); };
  38. virtual void WriteLock ( void ) { ::EnterCriticalSection (&m_cs); };
  39. virtual void WriteUnlock ( void ) { ::LeaveCriticalSection (&m_cs); };
  40. };
  41. #endif // _GENCRITICALSECTION_H