Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/hx/thread/CountingSemaphore.posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,22 @@ bool hx::thread::CountingSemaphore_obj::tryAcquire(Null<double> 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"));
}
}
}
}
2 changes: 2 additions & 0 deletions src/hx/thread/CountingSemaphore.win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down