diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2016-05-22 20:06:57 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2018-03-03 20:53:26 +0000 |
commit | fd207c06b81b12086bdf80e4fa7b393bf1f424d6 (patch) | |
tree | 1ef07d6c699ed66647207c9b42edbec2f11743d7 /src/corelib/thread/qwaitcondition_win.cpp | |
parent | 8c04a5e9640df0f1b2f533ee5fa698e2f466ad1f (diff) |
Port QWaitCondition to QDeadlineTimer
Since pthread_cond_timedwait takes absolute time instead of relative
time like most POSIX API, there's a small gain in performance here: we
avoid an extra system call to get the current time.
Task-number: QTBUG-64266
Change-Id: I25d85d86649448d5b2b3fffd1451138568091f50
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/thread/qwaitcondition_win.cpp')
-rw-r--r-- | src/corelib/thread/qwaitcondition_win.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/corelib/thread/qwaitcondition_win.cpp b/src/corelib/thread/qwaitcondition_win.cpp index e6610f18c8..61e4c2bcb1 100644 --- a/src/corelib/thread/qwaitcondition_win.cpp +++ b/src/corelib/thread/qwaitcondition_win.cpp @@ -38,6 +38,7 @@ ****************************************************************************/ #include "qwaitcondition.h" +#include "qdeadlinetimer.h" #include "qnamespace.h" #include "qmutex.h" #include "qreadwritelock.h" @@ -184,6 +185,11 @@ bool QWaitCondition::wait(QMutex *mutex, unsigned long time) return returnValue; } +bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline) +{ + return wait(mutex, deadline.remainingTime()); +} + bool QWaitCondition::wait(QReadWriteLock *readWriteLock, unsigned long time) { if (!readWriteLock) @@ -210,6 +216,11 @@ bool QWaitCondition::wait(QReadWriteLock *readWriteLock, unsigned long time) return returnValue; } +bool QWaitCondition::wait(QReadWriteLock *readWriteLock, QDeadlineTimer deadline) +{ + return wait(readWriteLock, deadline.remainingTime()); +} + void QWaitCondition::wakeOne() { // wake up the first waiting thread in the queue |