diff options
Diffstat (limited to 'src/corelib/thread/qsemaphore.cpp')
-rw-r--r-- | src/corelib/thread/qsemaphore.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index 012628ef63..6497792bf5 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -424,11 +424,9 @@ bool QSemaphore::tryAcquire(int n, int timeout) QDeadlineTimer timer(timeout); QMutexLocker locker(&d->mutex); - qint64 remainingTime = timer.remainingTime(); - while (n > d->avail && remainingTime != 0) { - if (!d->cond.wait(locker.mutex(), remainingTime)) + while (n > d->avail && !timer.hasExpired()) { + if (!d->cond.wait(locker.mutex(), timer)) return false; - remainingTime = timer.remainingTime(); } if (n > d->avail) return false; |