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.

33 lines
1000 B

  1. #ifndef _CRW_H
  2. #define _CRW_H
  3. #include <limits.h>
  4. //
  5. // This class contains the meat - does actual locking etc...
  6. //
  7. class CShareLock {
  8. private :
  9. long cReadLock ; // Number of Readers who have passed through the lock OR
  10. // the number of readers waiting for the lock (will be negative).
  11. // A value of 0 means nobody in the lock
  12. long cOutRdrs ; // The number of readers remainin in the lock if
  13. // there is a writer waiting. This can become temporarily negative
  14. CRITICAL_SECTION critWriters ; // Critical section to allow only one writer into the lock at a time
  15. HANDLE hWaitingWriters ; // Semaphore for waiting writers to block on (Only 1 ever, others will
  16. // be queued on critWriters)
  17. HANDLE hWaitingReaders ; // Semaphore for waiting readers to block on
  18. public :
  19. CShareLock( ) ;
  20. ~CShareLock( ) ;
  21. void ShareLock( ) ;
  22. void ShareUnlock( ) ;
  23. void ExclusiveLock( ) ;
  24. void ExclusiveUnlock( ) ;
  25. } ;
  26. #endif