[*] Unix should use absolute timeouts d'oh

This commit is contained in:
Reece Wilson 2021-10-03 13:43:37 +01:00
parent bd1d1a2aae
commit 6c0907fe9e
4 changed files with 11 additions and 3 deletions

View File

@ -43,7 +43,7 @@ namespace Aurora::Threading::Primitives
else
{
struct timespec tspec;
Time::ms2ts(&tspec, timeout);
Time::ms2tsabs(&tspec, timeout);
auto ret = pthread_cond_timedwait(&pthreadCv_, mutex, &tspec);

View File

@ -60,7 +60,7 @@ namespace Aurora::Threading::Primitives
else
{
struct timespec tspec;
Time::ms2ts(&tspec, timeout);
Time::ms2tsabs(&tspec, timeout);
auto ret = pthread_mutex_timedlock(&value_, &tspec);
if (ret != 0)

View File

@ -53,7 +53,7 @@ namespace Aurora::Threading::Primitives
else
{
struct timespec tspec;
Time::ms2ts(&tspec, timeout);
Time::ms2tsabs(&tspec, timeout);
auto ret = sem_timedwait(&value_, &tspec);
if (ret != 0)

View File

@ -19,6 +19,7 @@ namespace Aurora::Time
return ull.QuadPart / 10000ULL - 12'643'550'100'000ULL;
}
#elif defined(AURORA_IS_POSIX_DERIVED)
static inline AuUInt32 ConvertUnixTimespecToMs(const struct timespec &spec)
@ -32,5 +33,12 @@ namespace Aurora::Time
ts->tv_nsec = (ms % 1000) * 1000000;
}
static void ms2tsabs(struct timespec *ts, unsigned long ms)
{
ms += ConvertAuroraToUnixMS(CurrentClockMS());
ts->tv_sec = ms / 1000;
ts->tv_nsec = (ms % 1000) * 1000000;
}
#endif
}