Skip to content

Commit

Permalink
More reliable semaphore wait
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed Mar 9, 2018
1 parent 0bf7864 commit 7fbb6a7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Amicable/Platform_GCC_Linux.h
Expand Up @@ -160,7 +160,22 @@ class Semaphore
FORCEINLINE ~Semaphore() { sem_close(mySemaphore); sem_unlink(myName); }

FORCEINLINE bool Signal() { return (sem_post(mySemaphore) == 0); }
FORCEINLINE bool Wait() { return (sem_wait(mySemaphore) == 0); }

FORCEINLINE bool Wait()
{
while (sem_wait(mySemaphore))
{
if (errno == EINTR)
{
errno = 0;
}
else
{
return false;
}
}
return true;
}

private:
char myName[NAME_MAX];
Expand Down

0 comments on commit 7fbb6a7

Please sign in to comment.