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>
This commit is contained in:
Thiago Macieira 2013-03-30 10:26:11 -07:00 committed by The Qt Project
parent 786c790176
commit 2fbe972a65

View File

@ -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);
}