diff --git a/src/hx/thread/CountingSemaphore.posix.cpp b/src/hx/thread/CountingSemaphore.posix.cpp index bc6e9eddb..438c1974a 100644 --- a/src/hx/thread/CountingSemaphore.posix.cpp +++ b/src/hx/thread/CountingSemaphore.posix.cpp @@ -70,17 +70,22 @@ bool hx::thread::CountingSemaphore_obj::tryAcquire(Null timeout) t.tv_sec = tv.tv_sec + idelta + idelta2; t.tv_nsec = (long)delta; - switch (sem_timedwait(&impl->semaphore, &t)) + if (0 == sem_timedwait(&impl->semaphore, &t)) { - case 0: hx::ExitGCFreeZone(); return true; - case ETIMEDOUT: - hx::ExitGCFreeZone(); - return false; - default: + } + else + { hx::ExitGCFreeZone(); - return hx::Throw(HX_CSTRING("Failed to wait for semaphore")); + if (errno == ETIMEDOUT) + { + return false; + } + else + { + return hx::Throw(HX_CSTRING("Failed to wait for semaphore")); + } } } } \ No newline at end of file diff --git a/src/hx/thread/CountingSemaphore.win32.cpp b/src/hx/thread/CountingSemaphore.win32.cpp index 471cde866..e61cc9f49 100644 --- a/src/hx/thread/CountingSemaphore.win32.cpp +++ b/src/hx/thread/CountingSemaphore.win32.cpp @@ -34,6 +34,8 @@ void hx::thread::CountingSemaphore_obj::acquire() hx::ExitGCFreeZone(); hx::Throw(HX_CSTRING("Failed to wait for semaphore")); } + + hx::ExitGCFreeZone(); } void hx::thread::CountingSemaphore_obj::release()