RWLock.h
上传用户:jnsxzc
上传日期:2007-01-03
资源大小:25k
文件大小:1k
源码类别:

进程与线程

开发平台:

Visual C++

  1. // RWLock.h: interface for the CRWLock class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_RWLOCK_H__0F267374_9905_11D3_8D3E_00105AAA7BB6__INCLUDED_)
  5. #define AFX_RWLOCK_H__0F267374_9905_11D3_8D3E_00105AAA7BB6__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. class CRWLock  
  10. {
  11. public:
  12. int unlockWrite();
  13. int lockWrite();
  14. int unlockRead();
  15. int lockRead();
  16. CRWLock();
  17. virtual ~CRWLock();
  18. ////// Accessor functions
  19. int getWaitingWriters();
  20. int getWaitingReaders();
  21. int getLockCount();
  22. private:
  23. // Disallow copies of read write lock via copy and assignment
  24. CRWLock(const CRWLock&);
  25. operator =(const CRWLock &);
  26. int waitingWriter();
  27. int incrementWriters();
  28. int decrementWriters();
  29. int waitingReader();
  30. int incrementReaders();
  31. int decrementReaders();
  32. int m_nLockCount;
  33. int m_nWaitingWriters;
  34. int m_nWaitingReaders;
  35. HANDLE m_hReaderEvent;
  36. HANDLE m_hWriterEvent;
  37. HANDLE m_hLockCountMutex;
  38. };
  39. #endif // !defined(AFX_RWLOCK_H__0F267374_9905_11D3_8D3E_00105AAA7BB6__INCLUDED_)