Semaphore.cpp 1.6 KB

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