diff options
Diffstat (limited to 'src/corelib/thread/qsemaphore.cpp')
-rw-r--r-- | src/corelib/thread/qsemaphore.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index 74e0746f43..bb578ff617 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -39,8 +39,6 @@ ****************************************************************************/ #include "qsemaphore.h" - -#ifndef QT_NO_THREAD #include "qmutex.h" #include "qfutex_p.h" #include "qwaitcondition.h" @@ -487,11 +485,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; @@ -648,5 +644,3 @@ bool QSemaphore::tryAcquire(int n, int timeout) QT_END_NAMESPACE - -#endif // QT_NO_THREAD |