LockMgr.cpp
上传用户:jstlsd
上传日期:2007-01-13
资源大小:186k
文件大小:2k
源码类别:

钩子与API截获

开发平台:

Visual C++

  1. //---------------------------------------------------------------------------
  2. //
  3. // LockMgr.cpp
  4. //
  5. // SUBSYSTEM: 
  6. // Generic libraries
  7. // MODULE:    
  8. //
  9. //              Interface declaration of CCSWrapper CRITICAL_SECTION wrapper 
  10. // DESCRIPTION:
  11. //              
  12. //
  13. // AUTHOR: Ivo Ivanov (ivopi@hotmail.com)
  14. // DATE: 2001 November 13,  version 1.0 
  15. //                                                                         
  16. //---------------------------------------------------------------------------
  17. #include "LockMgr.h"
  18. //---------------------------------------------------------------------------
  19. //
  20. // class CCSWrapper 
  21. //
  22. // CRTICIAL_SECTION user object wrapper
  23. //
  24. //---------------------------------------------------------------------------
  25. //---------------------------------------------------------------------------
  26. //
  27. // Constructor
  28. //
  29. //---------------------------------------------------------------------------
  30. CCSWrapper::CCSWrapper()
  31. {
  32. m_nSpinCount = 0;
  33. ::InitializeCriticalSection( &m_cs );
  34. }
  35. //---------------------------------------------------------------------------
  36. //
  37. // Destructor
  38. //
  39. //---------------------------------------------------------------------------
  40. CCSWrapper::~CCSWrapper()
  41. {
  42. ::DeleteCriticalSection( &m_cs );
  43. }
  44. //---------------------------------------------------------------------------
  45. // Enter 
  46. //
  47. // This function waits for ownership of the specified critical section object 
  48. //---------------------------------------------------------------------------
  49. void CCSWrapper::Enter()
  50. {
  51. ::EnterCriticalSection( &m_cs );
  52. m_nSpinCount++;
  53. }
  54. //---------------------------------------------------------------------------
  55. // Leave
  56. //
  57. // Releases ownership of the specified critical section object. 
  58. //---------------------------------------------------------------------------
  59. void CCSWrapper::Leave()
  60. {
  61. m_nSpinCount--;
  62. ::LeaveCriticalSection( &m_cs );
  63. }
  64. //--------------------- End of the file -------------------------------------