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.

45 lines
1.3 KiB

  1. #ifndef kglobs_h
  2. #define kglobs_h
  3. // KRM global useful classes
  4. //-------------------------------------------------------------------------------------------------
  5. // Encapsulated a mutex. Best used as a class member
  6. class KCritMgr{
  7. friend class KCritical;
  8. public:
  9. KCritMgr();
  10. ~KCritMgr();
  11. bool isOK(){return allocatedOK;};
  12. protected:
  13. PKMUTEX myMutex;
  14. bool allocatedOK;
  15. };
  16. //-------------------------------------------------------------------------------------------------
  17. // Encapsulated the acuisition and release of a mutex in conjunction with KCritMgr.
  18. // Best used as an automatic
  19. class KCritical{
  20. public:
  21. KCritical(const KCritMgr& critMgr);
  22. ~KCritical();
  23. protected:
  24. PKMUTEX hisMutex;
  25. };
  26. //-------------------------------------------------------------------------------------------------
  27. // to 'Release' a COM interface on context destruction (a sort of 'smart pointer'.)
  28. // Best used as an automatic
  29. template<class T>
  30. class ReferenceAquirer{
  31. public:
  32. ReferenceAquirer(T& t):myT(t){return;};
  33. ~ReferenceAquirer(){myT->Release();};
  34. protected:
  35. T& myT;
  36. };
  37. //#undef _DbgPrintF
  38. //#define _DbgPrintF(lvl, strings) DbgPrint(STR_MODULENAME);DbgPrint##strings;DbgPrint("\n");
  39. //-------------------------------------------------------------------------------------------------
  40. #endif