[*] Update UNIX mutex primitive

This commit is contained in:
Reece Wilson 2022-04-13 16:06:26 +01:00
parent 4f2a2926e7
commit 0a6e1adfbf

View File

@ -69,13 +69,25 @@ namespace Aurora::Threading::Primitives
struct timespec tspec;
Time::ms2tsabs(&tspec, timeout);
auto ret = pthread_mutex_timedlock(&value_, &tspec);
if (ret != 0)
{
SysAssert(ret == ETIMEDOUT, "mutex timed lock failed");
return false;
}
int ret {};
do
{
ret = pthread_mutex_timedlock(&value_, &tspec);
if (ret == 0)
{
return true;
}
if (ret == ETIMEDOUT)
{
return false;
}
} while (ret == EINTR);
SysPanic("mutex timed lock failed {}", ret);
return true;
}
}