ConditionVariable.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #include "il2cpp-config.h"
  2. #include "os/ConditionVariable.h"
  3. #include "os/Mutex.h"
  4. #if IL2CPP_SUPPORT_THREADS
  5. #if IL2CPP_THREADS_WIN32
  6. #include "os/Win32/ConditionVariableImpl.h"
  7. #elif IL2CPP_THREADS_PTHREAD
  8. #include "os/Posix/ConditionVariableImpl.h"
  9. #else
  10. #include "os/ConditionVariableImpl.h"
  11. #endif
  12. namespace il2cpp
  13. {
  14. namespace os
  15. {
  16. ConditionVariable::ConditionVariable()
  17. : m_ConditionVariable(new ConditionVariableImpl())
  18. {
  19. }
  20. ConditionVariable::~ConditionVariable()
  21. {
  22. delete m_ConditionVariable;
  23. }
  24. int ConditionVariable::Wait(FastMutex* lock)
  25. {
  26. return m_ConditionVariable->Wait(lock->GetImpl());
  27. }
  28. int ConditionVariable::TimedWait(FastMutex* lock, uint32_t timeout_ms)
  29. {
  30. return m_ConditionVariable->TimedWait(lock->GetImpl(), timeout_ms);
  31. }
  32. void ConditionVariable::Broadcast()
  33. {
  34. m_ConditionVariable->Broadcast();
  35. }
  36. void ConditionVariable::Signal()
  37. {
  38. m_ConditionVariable->Signal();
  39. }
  40. }
  41. }
  42. #else
  43. namespace il2cpp
  44. {
  45. namespace os
  46. {
  47. ConditionVariable::ConditionVariable()
  48. {
  49. }
  50. ConditionVariable::~ConditionVariable()
  51. {
  52. }
  53. int ConditionVariable::Wait(FastMutex* lock)
  54. {
  55. IL2CPP_ASSERT(0 && "Threads are not enabled for this platform.");
  56. return 0;
  57. }
  58. int ConditionVariable::TimedWait(FastMutex* lock, uint32_t timeout_ms)
  59. {
  60. IL2CPP_ASSERT(0 && "Threads are not enabled for this platform.");
  61. return 0;
  62. }
  63. void ConditionVariable::Broadcast()
  64. {
  65. }
  66. void ConditionVariable::Signal()
  67. {
  68. }
  69. }
  70. }
  71. #endif