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.

79 lines
1.6 KiB

  1. /*
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. blbgen.h
  5. Abstract:
  6. Author:
  7. */
  8. #ifndef __BLB_GEN__
  9. #define __BLB_GEN__
  10. #include "blbdbg.h"
  11. #include <mspenum.h> // for CSafeComEnum
  12. const WCHAR_EOS = '\0';
  13. /////////////////////////////////////////////////////////////////////////////
  14. // my critical section
  15. /////////////////////////////////////////////////////////////////////////////
  16. class CCritSection
  17. {
  18. private:
  19. CRITICAL_SECTION m_CritSec;
  20. public:
  21. CCritSection()
  22. {
  23. InitializeCriticalSection(&m_CritSec);
  24. }
  25. ~CCritSection()
  26. {
  27. DeleteCriticalSection(&m_CritSec);
  28. }
  29. void Lock()
  30. {
  31. EnterCriticalSection(&m_CritSec);
  32. }
  33. void Unlock()
  34. {
  35. LeaveCriticalSection(&m_CritSec);
  36. }
  37. };
  38. /////////////////////////////////////////////////////////////////////////////
  39. // an auto lock that uses my critical section
  40. /////////////////////////////////////////////////////////////////////////////
  41. class CLock
  42. {
  43. private:
  44. CCritSection &m_CriticalSection;
  45. public:
  46. CLock(CCritSection &CriticalSection)
  47. : m_CriticalSection(CriticalSection)
  48. {
  49. m_CriticalSection.Lock();
  50. }
  51. ~CLock()
  52. {
  53. m_CriticalSection.Unlock();
  54. }
  55. };
  56. // This is the lock on this dll that simulate an apartment model.
  57. // per sdp lock is much better but it requires a lot of code changes.
  58. // Since this is not a time critical component, we can live with it.
  59. extern CCritSection g_DllLock;
  60. #endif // __BLB_GEN__