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.

97 lines
2.1 KiB

  1. //
  2. // MODULE: SYNC.H
  3. //
  4. // PURPOSE: syncronization classes
  5. //
  6. // COMPANY: Saltmine Creative, Inc. (206)-284-7511 [email protected]
  7. //
  8. // AUTHOR: Oleg Kalosha
  9. //
  10. // ORIGINAL DATE: 8-04-98
  11. //
  12. // NOTES:
  13. //
  14. // Version Date By Comments
  15. //--------------------------------------------------------------------
  16. // V3.0 08-04-98 OK
  17. //
  18. #ifndef __SYNC_H_
  19. #define __SYNC_H_
  20. #include <vector>
  21. #include <windows.h>
  22. using namespace std;
  23. ////////////////////////////////////////////////////////////////////////////////////
  24. // single sync object abstract class
  25. class CSyncObj
  26. {
  27. protected:
  28. HANDLE m_handle;
  29. public:
  30. CSyncObj();
  31. ~CSyncObj();
  32. public:
  33. virtual void Lock() =0;
  34. virtual void Unlock() =0;
  35. public:
  36. HANDLE GetHandle() const;
  37. };
  38. ////////////////////////////////////////////////////////////////////////////////////
  39. // single mutex object class
  40. // Manages a single mutex handle to facilitate waiting for the mutex.
  41. class CMutexObj : public CSyncObj
  42. {
  43. public:
  44. CMutexObj();
  45. ~CMutexObj();
  46. public:
  47. virtual void Lock();
  48. virtual void Unlock();
  49. };
  50. ////////////////////////////////////////////////////////////////////////////////////
  51. // multiple sync object abstract class
  52. // Manages multiple handles (the exact type of handle will be determined by a class
  53. // inheriting from this) to facilitate waiting for the union of several events.
  54. class CMultiSyncObj
  55. {
  56. protected:
  57. vector<HANDLE> m_arrHandle;
  58. public:
  59. CMultiSyncObj();
  60. ~CMultiSyncObj();
  61. public:
  62. void AddHandle(HANDLE);
  63. void RemoveHandle(HANDLE);
  64. void Clear();
  65. public:
  66. virtual void Lock() =0;
  67. virtual void Unlock() =0;
  68. };
  69. ////////////////////////////////////////////////////////////////////////////////////
  70. // multiple mutex object class
  71. // Manages multiple mutex handles to facilitate waiting for the union of several mutexes.
  72. class CMultiMutexObj : public CMultiSyncObj
  73. {
  74. public:
  75. CMultiMutexObj();
  76. ~CMultiMutexObj();
  77. public:
  78. virtual void Lock();
  79. virtual void Lock(LPCSTR srcFile, int srcLine, DWORD TimeOutVal=60000);
  80. virtual void Unlock();
  81. };
  82. #endif