Mutex.h 1002 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // "$Id: Mutex.h 120119 2013-06-04 11:12:32Z sun_xiaohui $"
  3. //
  4. // Copyright (c)1992-2007, ZheJiang Dahua Technology Stock CO.LTD.
  5. // All Rights Reserved.
  6. //
  7. // Description:
  8. // Revisions: Year-Month-Day SVN-Author Modification
  9. //
  10. #ifndef __INFRA3_MUTEX_H__
  11. #define __INFRA3_MUTEX_H__
  12. #include "Defs.h"
  13. //lint -save -e1509
  14. namespace Dahua{
  15. namespace Infra{
  16. struct MutexInternal;
  17. /// \class CMutex
  18. class INFRA_API CMutex
  19. {
  20. CMutex(CMutex const&);
  21. CMutex& operator=(CMutex const&);
  22. public:
  23. /// 构造函数,会创建系统互斥量
  24. CMutex();
  25. /// 析构函数,会销毁系统互斥量
  26. ~CMutex();
  27. /// 进入临界区。
  28. /// \return 操作是否成功
  29. bool enter();
  30. /// 尝试进入临界区,已经被占用直接返回,不等待。
  31. /// \return进入临界区是否成功
  32. bool tryEnter();
  33. /// 离开临界区。
  34. /// \return 操作是否成功
  35. bool leave();
  36. private:
  37. MutexInternal *m_internal;
  38. };
  39. } // namespace Infra
  40. } // namespace Dahua
  41. #endif //__INFRA_MUTEX_H__
  42. //
  43. // End of "$Id: Mutex.h 120119 2013-06-04 11:12:32Z sun_xiaohui $"
  44. //