Semaphore.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "os/c-api/il2cpp-config-platforms.h"
  2. #include "os/Semaphore.h"
  3. #if IL2CPP_SUPPORT_THREADS
  4. #include "os/Atomic.h"
  5. #if IL2CPP_TARGET_WINDOWS || IL2CPP_TARGET_POSIX
  6. #include "os/Generic/SemaphoreImpl.h"
  7. #else
  8. #include "os/SemaphoreImpl.h"
  9. #endif
  10. namespace il2cpp
  11. {
  12. namespace os
  13. {
  14. Semaphore::Semaphore(int32_t initialValue, int32_t maximumValue)
  15. : m_Semaphore(new SemaphoreImpl(initialValue, maximumValue))
  16. {
  17. }
  18. Semaphore::~Semaphore()
  19. {
  20. delete m_Semaphore;
  21. }
  22. bool Semaphore::Post(int32_t releaseCount, int32_t* previousCount)
  23. {
  24. return m_Semaphore->Post(releaseCount, previousCount);
  25. }
  26. WaitStatus Semaphore::Wait(bool interruptible)
  27. {
  28. return m_Semaphore->Wait(interruptible);
  29. }
  30. WaitStatus Semaphore::Wait(uint32_t ms, bool interruptible)
  31. {
  32. return m_Semaphore->Wait(ms, interruptible);
  33. }
  34. void* Semaphore::GetOSHandle()
  35. {
  36. return m_Semaphore->GetOSHandle();
  37. }
  38. }
  39. }
  40. #else
  41. namespace il2cpp
  42. {
  43. namespace os
  44. {
  45. Semaphore::Semaphore(int32_t initialValue, int32_t maximumValue)
  46. {
  47. }
  48. Semaphore::~Semaphore()
  49. {
  50. }
  51. bool Semaphore::Post(int32_t releaseCount, int32_t* previousCount)
  52. {
  53. return true;
  54. }
  55. WaitStatus Semaphore::Wait(bool interruptible)
  56. {
  57. return kWaitStatusSuccess;
  58. }
  59. WaitStatus Semaphore::Wait(uint32_t ms, bool interruptible)
  60. {
  61. return kWaitStatusSuccess;
  62. }
  63. void* Semaphore::GetOSHandle()
  64. {
  65. return NULL;
  66. }
  67. }
  68. }
  69. #endif