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:
parent
929da112ca
commit
d25ff2c7e2
@ -926,6 +926,19 @@ QThread::Priority QThread::priority() const
|
|||||||
|
|
||||||
\sa sleep(), terminate()
|
\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)
|
\fn void QThread::setTerminationEnabled(bool enabled)
|
||||||
|
@ -869,24 +869,6 @@ inline void QThreadPrivate::wakeAll()
|
|||||||
wakeAllInternal(this);
|
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)
|
bool QThreadPrivate::wait(QMutexLocker<QMutex> &locker, QDeadlineTimer deadline)
|
||||||
{
|
{
|
||||||
constexpr int HasJoinerBit = int(0x8000'0000); // a.k.a. sign bit
|
constexpr int HasJoinerBit = int(0x8000'0000); // a.k.a. sign bit
|
||||||
|
@ -414,20 +414,6 @@ void QThread::terminate()
|
|||||||
d->finish(false);
|
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)
|
bool QThreadPrivate::wait(QMutexLocker<QMutex> &locker, QDeadlineTimer deadline)
|
||||||
{
|
{
|
||||||
Q_ASSERT(threadState != QThreadPrivate::Finished);
|
Q_ASSERT(threadState != QThreadPrivate::Finished);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user