*/
QThreadPrivate::QThreadPrivate(QThreadData *d)
- : QObjectPrivate(), running(false), finished(false), terminated(false),
+ : QObjectPrivate(), running(false), finished(false),
isInFinish(false), exited(false), returnCode(-1),
stackSize(0), priority(QThread::InheritPriority), data(d)
{
\section1 Managing threads
- QThread will notifiy you via a signal
- when the thread is started(), finished(), and terminated(), or
- you can use isFinished() and isRunning() to query the state of
- the thread.
+ QThread will notifiy you via a signal when the thread is
+ started() and finished(), or you can use isFinished() and
+ isRunning() to query the state of the thread.
You can stop the thread by calling exit() or quit(). In extreme
cases, you may want to forcibly terminate() an executing thread.
This signal is emitted from the associated thread when it starts executing,
before the run() function is called.
- \sa finished(), terminated()
+ \sa finished()
*/
/*!
\note If the associated thread was terminated using terminate(), it is undefined from
which thread this signal is emitted.
- \sa started(), terminated()
-*/
-
-/*!
- \fn void QThread::terminated()
-
- This signal is emitted when the thread is terminated.
-
- It is undefined from which thread this signal is emitted.
-
- \sa started(), finished()
+ \sa started()
*/
/*!
Terminates the execution of the thread. The thread may or may not
be terminated immediately, depending on the operating system's
- scheduling policies. Listen for the terminated() signal, or use
- QThread::wait() after terminate(), to be sure.
+ scheduling policies. Use QThread::wait() after terminate(), to be
+ sure.
When the thread is terminated, all threads waiting for the thread
to finish will be woken up.
d->isInFinish = true;
d->priority = QThread::InheritPriority;
- bool terminated = d->terminated;
void *data = &d->data->tls;
locker.unlock();
- if (terminated)
- emit thr->terminated();
emit thr->finished();
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QThreadStorageData::finish((void **)data);
locker.relock();
- d->terminated = false;
QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher;
if (eventDispatcher) {
d->running = true;
d->finished = false;
- d->terminated = false;
d->returnCode = 0;
d->exited = false;
if (code) {
qWarning("QThread::start: Thread termination error: %s",
qPrintable(qt_error_string((code))));
- } else {
- d->terminated = true;
}
#endif
}
QMutexLocker locker(lockAnyway ? &d->mutex : 0);
d->isInFinish = true;
d->priority = QThread::InheritPriority;
- bool terminated = d->terminated;
void **tls_data = reinterpret_cast<void **>(&d->data->tls);
locker.unlock();
- if (terminated)
- emit thr->terminated();
emit thr->finished();
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QThreadStorageData::finish(tls_data);
locker.relock();
- d->terminated = false;
-
QAbstractEventDispatcher *eventDispatcher = d->data->eventDispatcher;
if (eventDispatcher) {
d->data->eventDispatcher = 0;
d->running = true;
d->finished = false;
- d->terminated = false;
d->exited = false;
d->returnCode = 0;
return;
}
TerminateThread(d->handle, 0);
- d->terminated = true;
QThreadPrivate::finish(this, false);
}
if (ret && !d->finished) {
// thread was terminated by someone else
- d->terminated = true;
+
QThreadPrivate::finish(this, false);
}
QMutexLocker locker(&d->mutex);
d->terminationEnabled = enabled;
if (enabled && d->terminatePending) {
- d->terminated = true;
QThreadPrivate::finish(thr, false);
locker.unlock(); // don't leave the mutex locked!
_endthreadex(0);