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.

69 lines
1.6 KiB

  1. // SharedMarker.h: interface for the CSharedMarker class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_SHAREDMARKER_H__8B7450C4_A2FD_11D3_A5D7_00104BD32DA8__INCLUDED_)
  5. #define AFX_SHAREDMARKER_H__8B7450C4_A2FD_11D3_A5D7_00104BD32DA8__INCLUDED_
  6. #include <string>
  7. #include <rpc.h>
  8. #include <scuOsExc.h>
  9. #include "Marker.h"
  10. namespace iop
  11. {
  12. class CSharedMarker
  13. {
  14. public:
  15. CSharedMarker(std::string const &strName);
  16. virtual ~CSharedMarker();
  17. CMarker Marker(CMarker::MarkerType const &Type);
  18. CMarker UpdateMarker(CMarker::MarkerType const &Type);
  19. private:
  20. void Initialize();
  21. void VerifyCheckSum(bool bRecover = false);
  22. void UpdateCheckSum();
  23. DWORD SharedMemorySize() {return sizeof(SharedMemoryData);};
  24. typedef struct {
  25. UUID ShMemID;
  26. CMarker::MarkerCounter CounterList[CMarker::MaximumMarker];
  27. __int32 CheckSum;
  28. } SharedMemoryData;
  29. SharedMemoryData *m_pShMemData;
  30. HANDLE m_hFileMap;
  31. HANDLE m_hMutex;
  32. // The Transaction class is is used to mutex protect critial sections
  33. // cross process boundaries.
  34. class Transaction {
  35. public:
  36. Transaction(HANDLE hMutex) : m_hMutex(hMutex)
  37. {
  38. if(WaitForSingleObject(m_hMutex,INFINITE)==WAIT_FAILED)
  39. throw scu::OsException(GetLastError());
  40. };
  41. ~Transaction() {
  42. try {
  43. ReleaseMutex(m_hMutex);
  44. }
  45. catch(...) {};
  46. };
  47. private:
  48. HANDLE m_hMutex;
  49. };
  50. };
  51. }
  52. #endif // !defined(AFX_SHAREDMARKER_H__8B7450C4_A2FD_11D3_A5D7_00104BD32DA8__INCLUDED_)