[*] Unix should use absolute timeouts d'oh
This commit is contained in:
parent
bd1d1a2aae
commit
6c0907fe9e
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user