From 2fbe972a656cf218e5b48c018618e464c878840c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 30 Mar 2013 10:26:11 -0700 Subject: [PATCH] Add a function to do the relative waits, simplifying the code a little More to come. Change-Id: I108f23e94c322ad4e1466ff69100ad6af91d95e9 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/corelib/thread/qwaitcondition_unix.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp index e3f8b2fff31..59c40352329 100644 --- a/src/corelib/thread/qwaitcondition_unix.cpp +++ b/src/corelib/thread/qwaitcondition_unix.cpp @@ -104,14 +104,19 @@ public: int waiters; int wakeups; + int wait_relative(unsigned long time) + { + timespec ti; + qt_abstime_for_timeout(&ti, time); + return pthread_cond_timedwait(&cond, &mutex, &ti); + } + bool wait(unsigned long time) { int code; forever { if (time != ULONG_MAX) { - timespec ti; - qt_abstime_for_timeout(&ti, time); - code = pthread_cond_timedwait(&cond, &mutex, &ti); + code = wait_relative(time); } else { code = pthread_cond_wait(&cond, &mutex); }