Skip to content

Commit de3fc20

Browse files
author
Aidan Lee
committed
Check errno
1 parent 6018294 commit de3fc20

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/hx/thread/CountingSemaphore.posix.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,22 @@ bool hx::thread::CountingSemaphore_obj::tryAcquire(Null<double> timeout)
7070
t.tv_sec = tv.tv_sec + idelta + idelta2;
7171
t.tv_nsec = (long)delta;
7272

73-
switch (sem_timedwait(&impl->semaphore, &t))
73+
if (0 == sem_timedwait(&impl->semaphore, &t))
7474
{
75-
case 0:
7675
hx::ExitGCFreeZone();
7776
return true;
78-
case ETIMEDOUT:
79-
hx::ExitGCFreeZone();
80-
return false;
81-
default:
77+
}
78+
else
79+
{
8280
hx::ExitGCFreeZone();
83-
return hx::Throw(HX_CSTRING("Failed to wait for semaphore"));
81+
if (errno == ETIMEDOUT)
82+
{
83+
return false;
84+
}
85+
else
86+
{
87+
return hx::Throw(HX_CSTRING("Failed to wait for semaphore"));
88+
}
8489
}
8590
}
8691
}

0 commit comments

Comments
 (0)