Semaphore.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "icalls/System/System.Threading/Semaphore.h"
  2. #include "os/Semaphore.h"
  3. #include "vm/Exception.h"
  4. namespace il2cpp
  5. {
  6. namespace icalls
  7. {
  8. namespace System
  9. {
  10. namespace System
  11. {
  12. namespace Threading
  13. {
  14. bool Semaphore::ReleaseSemaphore_internal(intptr_t handlePtr, int32_t releaseCount, int32_t* previousCount)
  15. {
  16. os::SemaphoreHandle* handle = (os::SemaphoreHandle*)handlePtr;
  17. return handle->Get().Post(releaseCount, previousCount);
  18. }
  19. intptr_t Semaphore::CreateSemaphore_icall(int32_t initialCount, int32_t maximumCount, Il2CppChar* name, int32_t name_length, int32_t* errorCode)
  20. {
  21. *errorCode = true;
  22. os::Semaphore* semaphore = NULL;
  23. if (name == NULL)
  24. semaphore = new os::Semaphore(initialCount, maximumCount);
  25. else
  26. NOT_SUPPORTED_IL2CPP(Semaphore::CreateSemaphore_internal, "Named semaphores are not supported.");
  27. return reinterpret_cast<intptr_t>(new os::SemaphoreHandle(semaphore));
  28. }
  29. intptr_t Semaphore::OpenSemaphore_icall(Il2CppChar* name, int32_t name_length, int32_t rights, int32_t* errorCode)
  30. {
  31. NOT_SUPPORTED_IL2CPP(Semaphore::OpenSemaphore_internal, "Named semaphores are not supported.");
  32. return 0;
  33. }
  34. } /* namespace Threading */
  35. } /* namespace System */
  36. } /* namespace System */
  37. } /* namespace icalls */
  38. } /* namespace il2cpp */