QThread/Doc: improve docs on running, finished, and the OS thread
And take the opportunity to explain that the finished() signal does not indicate the end of the operating system thread. Indeed, on some OSes, not even wait() can be sure of that: for Unix systems, see the docs at the top of qthread_unix.cpp about timed pthread_joins. Pick-to: 6.8 Fixes: QTBUG-135163 Change-Id: Ie00a742f0707f57c767bfffd44bdaec40df05e4a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io> (cherry picked from commit de90f2e064ffef2ed751b7805d81a93668dc67a2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
f2b58861d2
commit
013793a783
@ -470,6 +470,16 @@ QThread::~QThread()
|
||||
\threadsafe
|
||||
Returns \c true if the thread is finished; otherwise returns \c false.
|
||||
|
||||
A thread is considered finished if it has returned from the run() function
|
||||
and the finished() signal has been emitted.
|
||||
|
||||
//! [execution-after-finished]
|
||||
Note the thread may still run for arbitrary amount of time after the
|
||||
finished() signal is emitted, running clean-up operations such as executing
|
||||
the destructors to \c{thread_local} variables. To synchronize with all
|
||||
effects from the thread, call wait() and verify it returned true.
|
||||
//! [execution-after-finished]
|
||||
|
||||
\sa isRunning()
|
||||
*/
|
||||
bool QThread::isFinished() const
|
||||
@ -483,6 +493,11 @@ bool QThread::isFinished() const
|
||||
\threadsafe
|
||||
Returns \c true if the thread is running; otherwise returns \c false.
|
||||
|
||||
A thread is considered to be running if QThread has been started with
|
||||
start() but is not yet finished.
|
||||
|
||||
\include qthread.cpp execution-after-finished
|
||||
|
||||
\sa isFinished()
|
||||
*/
|
||||
bool QThread::isRunning() const
|
||||
@ -924,6 +939,12 @@ QThread::Priority QThread::priority() const
|
||||
This provides similar functionality to the POSIX \c
|
||||
pthread_join() function.
|
||||
|
||||
\note On some operating systems, this function may return true while the
|
||||
operating system thread is still running and may be executing clean-up code
|
||||
such as C++11 \c{thread_local} destructors. Operating systems where this
|
||||
function only returns true after the OS thread has fully exited include
|
||||
Linux, Windows, and Apple operating systems.
|
||||
|
||||
\sa sleep(), terminate()
|
||||
*/
|
||||
bool QThread::wait(QDeadlineTimer deadline)
|
||||
|
Loading…
x
Reference in New Issue
Block a user