diff options
author | João Abecasis <joao.abecasis@nokia.com> | 2011-01-05 14:24:50 (GMT) |
---|---|---|
committer | Qt Commercial Integration <QtCommercial@digia.com> | 2012-01-31 10:24:42 (GMT) |
commit | dd5a778af3c75b8b12d3fb29fadacad2c1f69130 (patch) | |
tree | 38b44266085c9a5c4fb093c45366f7a888a33557 /src/corelib/thread | |
parent | c4ab78690b127e2a705d5a5386794229a67b496c (diff) | |
download | Qt-dd5a778af3c75b8b12d3fb29fadacad2c1f69130.zip Qt-dd5a778af3c75b8b12d3fb29fadacad2c1f69130.tar.gz Qt-dd5a778af3c75b8b12d3fb29fadacad2c1f69130.tar.bz2 |
Check elapsed time only once
Task-number: QTBUG-16262
Reviewed-by: Bradley T. Hughes
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qsemaphore.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index 3c04f28..46c1a1d 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -223,8 +223,9 @@ bool QSemaphore::tryAcquire(int n, int timeout) QElapsedTimer timer; timer.start(); while (n > d->avail) { - if (timer.hasExpired(timeout) - || !d->cond.wait(locker.mutex(), timeout - timer.elapsed())) + const qint64 elapsed = timer.elapsed(); + if (timeout - elapsed > 0 + || !d->cond.wait(locker.mutex(), timeout - elapsed)) return false; } } |