ConditionVariableImpl.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "os/c-api/il2cpp-config-platforms.h"
  2. #if IL2CPP_THREADS_WIN32 && !RUNTIME_TINY
  3. #include "WindowsHeaders.h"
  4. #include "os/Win32/MutexImpl.h"
  5. #include "ConditionVariableImpl.h"
  6. #include "WindowsHelpers.h"
  7. namespace il2cpp
  8. {
  9. namespace os
  10. {
  11. ConditionVariableImpl::ConditionVariableImpl()
  12. {
  13. ::InitializeConditionVariable(&m_ConditionVariable);
  14. }
  15. ConditionVariableImpl::~ConditionVariableImpl()
  16. {
  17. /* Beauty of win32 API: do not destroy it */
  18. }
  19. int ConditionVariableImpl::Wait(FastMutexImpl* lock)
  20. {
  21. return ::SleepConditionVariableCS(&m_ConditionVariable, lock->GetOSHandle(), INFINITE) ? 0 : 1;
  22. }
  23. int ConditionVariableImpl::TimedWait(FastMutexImpl* lock, uint32_t timeout_ms)
  24. {
  25. return ::SleepConditionVariableCS(&m_ConditionVariable, lock->GetOSHandle(), timeout_ms) ? 0 : 1;
  26. }
  27. void ConditionVariableImpl::Broadcast()
  28. {
  29. ::WakeAllConditionVariable(&m_ConditionVariable);
  30. }
  31. void ConditionVariableImpl::Signal()
  32. {
  33. ::WakeConditionVariable(&m_ConditionVariable);
  34. }
  35. }
  36. }
  37. #endif