QThread: move the identical Unix+Windows wait() functions to qthread.cpp

Change-Id: If94c9bc5ca5349b6a028fffd1ec6c6a04ff94c07
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Thiago Macieira 2024-11-06 08:30:23 -08:00
parent 929da112ca
commit d25ff2c7e2
3 changed files with 13 additions and 32 deletions

View File

@ -926,6 +926,19 @@ QThread::Priority QThread::priority() const
\sa sleep(), terminate()
*/
bool QThread::wait(QDeadlineTimer deadline)
{
Q_D(QThread);
QMutexLocker locker(&d->mutex);
if (d->threadState == QThreadPrivate::NotStarted || d->threadState == QThreadPrivate::Finished)
return true;
if (isCurrentThread()) {
qWarning("QThread::wait: Thread tried to wait on itself");
return false;
}
return d->wait(locker, deadline);
}
/*!
\fn void QThread::setTerminationEnabled(bool enabled)

View File

@ -869,24 +869,6 @@ inline void QThreadPrivate::wakeAll()
wakeAllInternal(this);
}
bool QThread::wait(QDeadlineTimer deadline)
{
Q_D(QThread);
QMutexLocker locker(&d->mutex);
if (d->threadState == QThreadPrivate::NotStarted)
return true;
if (d->threadState == QThreadPrivate::Finished)
return true;
if (isCurrentThread()) {
qWarning("QThread::wait: Thread tried to wait on itself");
return false;
}
return d->wait(locker, deadline);
}
bool QThreadPrivate::wait(QMutexLocker<QMutex> &locker, QDeadlineTimer deadline)
{
constexpr int HasJoinerBit = int(0x8000'0000); // a.k.a. sign bit

View File

@ -414,20 +414,6 @@ void QThread::terminate()
d->finish(false);
}
bool QThread::wait(QDeadlineTimer deadline)
{
Q_D(QThread);
QMutexLocker locker(&d->mutex);
if (isCurrentThread()) {
qWarning("QThread::wait: Thread tried to wait on itself");
return false;
}
if (d->threadState == QThreadPrivate::NotStarted || d->threadState == QThreadPrivate::Finished)
return true;
return d->wait(locker, deadline);
}
bool QThreadPrivate::wait(QMutexLocker<QMutex> &locker, QDeadlineTimer deadline)
{
Q_ASSERT(threadState != QThreadPrivate::Finished);