summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-11-06 17:59:49 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-11-07 10:53:16 +0100
commit72f57cc84244633ca69ede9a1fd510b9b1881c1d (patch)
treef76a0c43f97e936d77225dd499a7212cc562273f /src/corelib/thread
parentfa2c9a27e2a4b6ce59823f2f3c6c53a57e7c037f (diff)
QWaitCondition: mark obsolete functions as deprecated
Mark QWaitCondition:wait(..., ulong) as deprecated so they can be removed in Qt6. Also replace the usages of this deprecated functions inside QtCore. Change-Id: I77313255fa05f5c112b0b40d4c55339cc4f85346 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r--src/corelib/thread/qreadwritelock.cpp4
-rw-r--r--src/corelib/thread/qthread_unix.cpp2
-rw-r--r--src/corelib/thread/qthreadpool.cpp2
-rw-r--r--src/corelib/thread/qwaitcondition.h20
-rw-r--r--src/corelib/thread/qwaitcondition.qdoc34
-rw-r--r--src/corelib/thread/qwaitcondition_unix.cpp4
6 files changed, 42 insertions, 24 deletions
diff --git a/src/corelib/thread/qreadwritelock.cpp b/src/corelib/thread/qreadwritelock.cpp
index 14654986a0..c8463de402 100644
--- a/src/corelib/thread/qreadwritelock.cpp
+++ b/src/corelib/thread/qreadwritelock.cpp
@@ -477,7 +477,7 @@ bool QReadWriteLockPrivate::lockForRead(int timeout)
if (elapsed > timeout)
return false;
waitingReaders++;
- readerCond.wait(&mutex, timeout - elapsed);
+ readerCond.wait(&mutex, QDeadlineTimer(timeout - elapsed));
} else {
waitingReaders++;
readerCond.wait(&mutex);
@@ -511,7 +511,7 @@ bool QReadWriteLockPrivate::lockForWrite(int timeout)
return false;
}
waitingWriters++;
- writerCond.wait(&mutex, timeout - elapsed);
+ writerCond.wait(&mutex, QDeadlineTimer(timeout - elapsed));
} else {
waitingWriters++;
writerCond.wait(&mutex);
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index cb3c0d6bb1..b19922753a 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -765,7 +765,7 @@ bool QThread::wait(unsigned long time)
return true;
while (d->running) {
- if (!d->thread_done.wait(locker.mutex(), time))
+ if (!d->thread_done.wait(locker.mutex(), QDeadlineTimer(time)))
return false;
}
return true;
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp
index 4d2389f699..5f23a78c8a 100644
--- a/src/corelib/thread/qthreadpool.cpp
+++ b/src/corelib/thread/qthreadpool.cpp
@@ -136,7 +136,7 @@ void QThreadPoolThread::run()
manager->waitingThreads.enqueue(this);
registerThreadInactive();
// wait for work, exiting after the expiry timeout is reached
- runnableReady.wait(locker.mutex(), manager->expiryTimeout);
+ runnableReady.wait(locker.mutex(), QDeadlineTimer(manager->expiryTimeout));
++manager->activeThreads;
if (manager->waitingThreads.removeOne(this))
expired = true;
diff --git a/src/corelib/thread/qwaitcondition.h b/src/corelib/thread/qwaitcondition.h
index 11520e4cfe..86e2141f84 100644
--- a/src/corelib/thread/qwaitcondition.h
+++ b/src/corelib/thread/qwaitcondition.h
@@ -40,15 +40,12 @@
#ifndef QWAITCONDITION_H
#define QWAITCONDITION_H
-#include <QtCore/qglobal.h>
-
-#include <limits.h>
+#include <QDeadlineTimer>
QT_BEGIN_NAMESPACE
#if QT_CONFIG(thread)
-class QDeadlineTimer;
class QWaitConditionPrivate;
class QMutex;
class QReadWriteLock;
@@ -59,11 +56,16 @@ public:
QWaitCondition();
~QWaitCondition();
- // ### Qt 6: remove unsigned long overloads
- bool wait(QMutex *lockedMutex, unsigned long time = ULONG_MAX);
- bool wait(QMutex *lockedMutex, QDeadlineTimer deadline);
- bool wait(QReadWriteLock *lockedReadWriteLock, unsigned long time = ULONG_MAX);
- bool wait(QReadWriteLock *lockedReadWriteLock, QDeadlineTimer deadline);
+ bool wait(QMutex *lockedMutex,
+ QDeadlineTimer deadline = QDeadlineTimer(QDeadlineTimer::Forever));
+ bool wait(QReadWriteLock *lockedReadWriteLock,
+ QDeadlineTimer deadline = QDeadlineTimer(QDeadlineTimer::Forever));
+#if QT_DEPRECATED_SINCE(5, 15)
+ QT_DEPRECATED_VERSION_X_5_15("Use wait(QMutex *lockedMutex, QDeadlineTimer deadline) instead")
+ bool wait(QMutex *lockedMutex, unsigned long time);
+ QT_DEPRECATED_VERSION_X_5_15("Use wait(QReadWriteLock *lockedReadWriteLock, QDeadlineTimer deadline) instead")
+ bool wait(QReadWriteLock *lockedReadWriteLock, unsigned long time);
+#endif
void wakeOne();
void wakeAll();
diff --git a/src/corelib/thread/qwaitcondition.qdoc b/src/corelib/thread/qwaitcondition.qdoc
index eebc28f059..9da6f6f25c 100644
--- a/src/corelib/thread/qwaitcondition.qdoc
+++ b/src/corelib/thread/qwaitcondition.qdoc
@@ -119,10 +119,22 @@
\sa wakeOne()
*/
+#if QT_DEPRECATED_SINCE(5, 15)
/*!
\fn bool QWaitCondition::wait(QMutex *lockedMutex, unsigned long time)
+ \obsolete use wait(QMutex *lockedMutex, QDeadlineTimer deadline) instead
+*/
+/*!
+ \fn bool QWaitCondition::wait(QReadWriteLock *lockedReadWriteLock, unsigned long time)
+ \obsolete use wait(QReadWriteLock *lockedReadWriteLock, QDeadlineTimer deadline) instead
+*/
+#endif
- Releases the \a lockedMutex and waits on the wait condition. The
+/*!
+ \fn bool QWaitCondition::wait(QMutex *lockedMutex, QDeadlineTimer deadline)
+ \since 5.12
+
+ Releases the \a lockedMutex and waits on the wait condition. The
\a lockedMutex must be initially locked by the calling thread. If \a
lockedMutex is not in a locked state, the behavior is undefined. If
\a lockedMutex is a recursive mutex, this function
@@ -132,10 +144,10 @@
\list
\li Another thread signals it using wakeOne() or wakeAll(). This
function will return true in this case.
- \li \a time milliseconds has elapsed. If \a time is \c ULONG_MAX
- (the default), then the wait will never timeout (the event
- must be signalled). This function will return false if the
- wait timed out.
+ \li the deadline given by \a deadline is reached. If \a deadline is
+ \c QDeadlineTimer::Forever (the default), then the wait will never
+ timeout (the event must be signalled). This function will return
+ false if the wait timed out.
\endlist
The \a lockedMutex will be returned to the same locked state. This
@@ -146,8 +158,8 @@
*/
/*!
- \fn bool QWaitCondition::wait(QReadWriteLock *lockedReadWriteLock, unsigned long time)
- \since 4.4
+ \fn bool QWaitCondition::wait(QReadWriteLock *lockedReadWriteLock, QDeadlineTimer deadline)
+ \since 5.12
Releases the \a lockedReadWriteLock and waits on the wait
condition. The \a lockedReadWriteLock must be initially locked by the
@@ -160,10 +172,10 @@
\list
\li Another thread signals it using wakeOne() or wakeAll(). This
function will return true in this case.
- \li \a time milliseconds has elapsed. If \a time is \c ULONG_MAX
- (the default), then the wait will never timeout (the event
- must be signalled). This function will return false if the
- wait timed out.
+ \li the deadline given by \a deadline is reached. If \a deadline is
+ \c QDeadlineTimer::Forever (the default), then the wait will never
+ timeout (the event must be signalled). This function will return
+ false if the wait timed out.
\endlist
The \a lockedReadWriteLock will be returned to the same locked
diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp
index dd7475cec5..a8dfb9999c 100644
--- a/src/corelib/thread/qwaitcondition_unix.cpp
+++ b/src/corelib/thread/qwaitcondition_unix.cpp
@@ -202,12 +202,14 @@ void QWaitCondition::wakeAll()
report_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeAll()", "mutex unlock");
}
+#if QT_DEPRECATED_SINCE(5, 15)
bool QWaitCondition::wait(QMutex *mutex, unsigned long time)
{
if (time == std::numeric_limits<unsigned long>::max())
return wait(mutex, QDeadlineTimer(QDeadlineTimer::Forever));
return wait(mutex, QDeadlineTimer(time));
}
+#endif
bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
{
@@ -229,12 +231,14 @@ bool QWaitCondition::wait(QMutex *mutex, QDeadlineTimer deadline)
return returnValue;
}
+#if QT_DEPRECATED_SINCE(5, 15)
bool QWaitCondition::wait(QReadWriteLock *readWriteLock, unsigned long time)
{
if (time == std::numeric_limits<unsigned long>::max())
return wait(readWriteLock, QDeadlineTimer(QDeadlineTimer::Forever));
return wait(readWriteLock, QDeadlineTimer(time));
}
+#endif
bool QWaitCondition::wait(QReadWriteLock *readWriteLock, QDeadlineTimer deadline)
{