diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-03-30 10:26:11 -0700 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-02 19:01:27 +0200 |
commit | 2fbe972a656cf218e5b48c018618e464c878840c (patch) | |
tree | 9f007cb9156babcc7c52871efe427429e86f53aa /src/corelib/thread | |
parent | 786c790176461dbccc130d675b964017088105b7 (diff) | |
download | qtbase-2fbe972a656cf218e5b48c018618e464c878840c.tar.gz |
Add a function to do the relative waits, simplifying the code a little
More to come.
Change-Id: I108f23e94c322ad4e1466ff69100ad6af91d95e9
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qwaitcondition_unix.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp index e3f8b2fff3..59c4035232 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); } |