diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-11-25 01:00:25 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-11-25 11:30:04 +0100 |
commit | 58c69df4d38324644bc49ec5f42ee8343a454b2d (patch) | |
tree | de0a1ce603292dcaff134d4e1e8ab064295515a2 /src/corelib/thread/qthread.cpp | |
parent | 03b1d2c44940322208c12c7bceee376b51d8e852 (diff) | |
parent | 59a705e3710b0ba93bb698e3223241cfac932948 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
src/corelib/tools/qhash.h
src/gui/kernel/qevent.h
src/widgets/kernel/qshortcut.cpp
src/widgets/kernel/qshortcut.h
Change-Id: If61c206ee43ad1d97f5b07f58ac93c4583ce5620
Diffstat (limited to 'src/corelib/thread/qthread.cpp')
-rw-r--r-- | src/corelib/thread/qthread.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 6a59043881..1248a53160 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -49,6 +49,8 @@ #include "qthread_p.h" #include "private/qcoreapplication_p.h" +#include <limits> + QT_BEGIN_NAMESPACE /* @@ -726,7 +728,8 @@ QThread::Priority QThread::priority() const */ /*! - \fn bool QThread::wait(unsigned long time) + \fn bool QThread::wait(QDeadlineTimer deadline) + \since 5.15 Blocks the thread until either of these conditions is met: @@ -735,12 +738,14 @@ QThread::Priority QThread::priority() const execution (i.e. when it returns from \l{run()}). This function will return true if the thread has finished. It also returns true if the thread has not been started yet. - \li \a time milliseconds has elapsed. If \a time is ULONG_MAX (the - default), then the wait will never timeout (the thread must - return from \l{run()}). This function will return false if the - wait timed out. + \li The \a deadline is reached. This function will return false if the + deadline is reached. \endlist + A deadline timer set to \c QDeadlineTimer::Forever (the default) will never + time out: in this case, the function only returns when the thread returns + from \l{run()} or if the thread has not yet started. + This provides similar functionality to the POSIX \c pthread_join() function. @@ -833,9 +838,9 @@ void QThread::exit(int returnCode) } } -bool QThread::wait(unsigned long time) +bool QThread::wait(QDeadlineTimer deadline) { - Q_UNUSED(time); + Q_UNUSED(deadline); return false; } @@ -966,6 +971,17 @@ void QThread::setEventDispatcher(QAbstractEventDispatcher *eventDispatcher) } } +/*! + \fn bool QThread::wait(unsigned long time) + \overload +*/ +bool QThread::wait(unsigned long time) +{ + if (time == std::numeric_limits<unsigned long>::max()) + return wait(QDeadlineTimer(QDeadlineTimer::Forever)); + return wait(QDeadlineTimer(time)); +} + #if QT_CONFIG(thread) /*! |