暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #include "il2cpp-config.h"
  2. #include "os/Mutex.h"
  3. #if IL2CPP_SUPPORT_THREADS
  4. #include "os/Atomic.h"
  5. #if IL2CPP_THREADS_WIN32 || IL2CPP_THREADS_PTHREAD
  6. #if IL2CPP_THREADS_WIN32
  7. #include "os/Win32/MutexImpl.h"
  8. #elif IL2CPP_THREADS_PTHREAD
  9. #include "os/Posix/MutexImpl.h"
  10. #endif
  11. #include "os/Generic/MutexImpl.h"
  12. #elif IL2CPP_TARGET_PSP2
  13. #include "os/PSP2/MutexImpl.h"
  14. #else
  15. #include "os/MutexImpl.h"
  16. #endif
  17. namespace il2cpp
  18. {
  19. namespace os
  20. {
  21. Mutex::Mutex(bool initiallyOwned)
  22. : m_Mutex(new MutexImpl())
  23. {
  24. if (initiallyOwned)
  25. Lock();
  26. }
  27. Mutex::~Mutex()
  28. {
  29. delete m_Mutex;
  30. }
  31. void Mutex::Lock(bool interruptible)
  32. {
  33. m_Mutex->Lock(interruptible);
  34. }
  35. bool Mutex::TryLock(uint32_t milliseconds, bool interruptible)
  36. {
  37. return m_Mutex->TryLock(milliseconds, interruptible);
  38. }
  39. void Mutex::Unlock()
  40. {
  41. m_Mutex->Unlock();
  42. }
  43. void* Mutex::GetOSHandle()
  44. {
  45. return m_Mutex->GetOSHandle();
  46. }
  47. FastMutex::FastMutex()
  48. : m_Impl(new FastMutexImpl())
  49. {
  50. }
  51. FastMutex::~FastMutex()
  52. {
  53. delete m_Impl;
  54. }
  55. void FastMutex::Lock()
  56. {
  57. m_Impl->Lock();
  58. }
  59. void FastMutex::Unlock()
  60. {
  61. m_Impl->Unlock();
  62. }
  63. FastMutexImpl* FastMutex::GetImpl()
  64. {
  65. return m_Impl;
  66. }
  67. }
  68. }
  69. #else
  70. namespace il2cpp
  71. {
  72. namespace os
  73. {
  74. Mutex::Mutex(bool initiallyOwned)
  75. {
  76. }
  77. Mutex::~Mutex()
  78. {
  79. }
  80. void Mutex::Lock(bool interruptible)
  81. {
  82. }
  83. bool Mutex::TryLock(uint32_t milliseconds, bool interruptible)
  84. {
  85. return true;
  86. }
  87. void Mutex::Unlock()
  88. {
  89. }
  90. void* Mutex::GetOSHandle()
  91. {
  92. return NULL;
  93. }
  94. FastMutex::FastMutex()
  95. {
  96. }
  97. FastMutex::~FastMutex()
  98. {
  99. }
  100. void FastMutex::Lock()
  101. {
  102. }
  103. void FastMutex::Unlock()
  104. {
  105. }
  106. FastMutexImpl* FastMutex::GetImpl()
  107. {
  108. IL2CPP_ASSERT(0 && "Threads are not enabled for this platform.");
  109. return NULL;
  110. }
  111. }
  112. }
  113. #endif