[*] Update UNIX mutex primitive
This commit is contained in:
parent
4f2a2926e7
commit
0a6e1adfbf
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user