From 1ea419fa5dcfa91666239d6ff86520605f95ba51 Mon Sep 17 00:00:00 2001 From: Bob van Loosen Date: Sun, 26 Feb 2012 23:16:58 +0100 Subject: [PATCH] fixed: the timeout value of pthread_cond_timedwait has to be referenced to CLOCK_REALTIME --- src/lib/platform/posix/os-threads.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib/platform/posix/os-threads.h b/src/lib/platform/posix/os-threads.h index 5216ffe..c37beed 100644 --- a/src/lib/platform/posix/os-threads.h +++ b/src/lib/platform/posix/os-threads.h @@ -48,13 +48,12 @@ namespace PLATFORM inline struct timespec GetAbsTime(uint64_t iIncreaseBy = 0) { - struct timespec abstime; - struct timeval now; - gettimeofday(&now, NULL); - iIncreaseBy += now.tv_usec / 1000; - abstime.tv_sec = now.tv_sec + (time_t)(iIncreaseBy / 1000); - abstime.tv_nsec = (int32_t)((iIncreaseBy % (uint32_t)1000) * (uint32_t)1000000); - return abstime; + struct timespec now; + clock_gettime(CLOCK_REALTIME, &now); + now.tv_nsec += iIncreaseBy % 1000 * 1000000; + now.tv_sec += iIncreaseBy / 1000 + now.tv_nsec / 1000000000; + now.tv_nsec %= 1000000000; + return now; } typedef pthread_t thread_t; -- 2.34.1