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.

93 lines
1.7 KiB

  1. #ifndef __MUTEXWRP_H__
  2. #define __MUTEXWRP_H__
  3. #include <Mutex.hxx>
  4. template <MUTEX * const &m> class MutexWrap
  5. {
  6. public:
  7. inline void Free(void)
  8. {
  9. m->Free();
  10. }
  11. inline BOOL TryRequest(void)
  12. {
  13. return m->TryRequest();
  14. }
  15. inline void Request(void)
  16. {
  17. m->Request();
  18. }
  19. inline void Clear(void)
  20. {
  21. m->Clear();
  22. }
  23. inline void VerifyOwned(void)
  24. {
  25. m->VerifyOwned();
  26. }
  27. inline void VerifyNotOwned(void)
  28. {
  29. m->VerifyNotOwned();
  30. }
  31. inline DWORD SetSpinCount(unsigned long Count)
  32. {
  33. return m->SetSpinCount(Count);
  34. }
  35. };
  36. typedef void (*MutexRequestFn) (void);
  37. typedef void (*MutexClearFn) (void);
  38. typedef void (*MutexVerifyOwnedFn) (void);
  39. typedef void (*MutexVerifyNotOwnedFn) (void);
  40. typedef BOOL (*MutexTryRequestFn) (void);
  41. typedef DWORD (*MutexSetSpinCountFn) (unsigned long Count);
  42. template <MutexRequestFn RequestFn, MutexClearFn ClearFn, MutexTryRequestFn TryRequestFn,
  43. MutexVerifyOwnedFn VerifyOwnedFn, MutexVerifyNotOwnedFn VerifyNotOwnedFn,
  44. MutexSetSpinCountFn SetSpinCountFn> class MutexWrap2
  45. {
  46. public:
  47. inline BOOL TryRequest(void)
  48. {
  49. return TryRequestFn();
  50. }
  51. inline void Request(void)
  52. {
  53. RequestFn();
  54. }
  55. inline void Clear(void)
  56. {
  57. ClearFn();
  58. }
  59. inline void VerifyOwned(void)
  60. {
  61. VerifyOwnedFn();
  62. }
  63. inline void VerifyNotOwned(void)
  64. {
  65. VerifyNotOwnedFn();
  66. }
  67. inline DWORD SetSpinCount(unsigned long Count)
  68. {
  69. return SetSpinCountFn(Count);
  70. }
  71. };
  72. #endif