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.

50 lines
1.3 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997
  5. //
  6. // File: PropLock.hxx
  7. //
  8. // Contents: Property store record locking class
  9. //
  10. // Classes: CPropertyLockMgr
  11. //
  12. // History: 23-Feb-96 dlee Created
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. //+-------------------------------------------------------------------------
  17. //
  18. // Class: CPropertyLockMgr
  19. //
  20. // Purpose: Handles locking for records in the property store
  21. //
  22. // History: 23-Feb-96 dlee Created
  23. //
  24. //----------------------------------------------------------------------------
  25. class CPropertyLockMgr
  26. {
  27. public:
  28. CPropertyLockMgr() { RtlZeroMemory( _aRecords, sizeof _aRecords ); }
  29. CReadWriteLockRecord & GetRecord( WORKID wid )
  30. {
  31. return _aRecords[ wid & ( cWidHash - 1 ) ];
  32. }
  33. // Return the number of unique records used to implement locking
  34. ULONG UniqueRecordCount() { return cWidHash; }
  35. // Always return the bucket you are computing in GetRecord...
  36. ULONG RecordIdForWid( WORKID wid ) { return wid & (cWidHash - 1); }
  37. private:
  38. enum { cWidHash = 256 };
  39. CReadWriteLockRecord _aRecords[ cWidHash ];
  40. };