Doc: Remove page about how to start QThreads

Multiple issues:
- Incomplete: It doesn't talk about instantiating a raw QThread
- Redundant: Its contents are already presented in QThread's class ref
- Incorrect: It is legal to create a QThread before a QCoreApplication
- Irrelevant: The bit about QCoreApplication::exec() and the etymology
  of "GUI thread" is unrelated to the topic of starting threads

Also remove snippets that are no longer used

Change-Id: Ice1819845b5b2cf843719edaa7b0f4bbb1e8bd97
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Sze Howe Koh 2013-09-08 17:33:41 +08:00 committed by The Qt Project
parent 5852ddb110
commit 6780f76ee0
3 changed files with 2 additions and 114 deletions

View File

@ -42,16 +42,6 @@
#include <QMutex>
#include <QThreadStorage>
#include "threads.h"
//! [0]
void MyThread::run()
//! [0] //! [1]
{
//! [1] //! [2]
}
//! [2]
#define Counter ReentrantCounter
//! [3]

View File

@ -1,51 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QThread>
//! [0]
class MyThread : public QThread
{
Q_OBJECT
protected:
void run();
};
//! [0]

View File

@ -60,7 +60,6 @@
\li \l{Recommended Reading}
\li \l{The Threading Classes}
\li \l{Multithreading Technologies in Qt}
\li \l{Starting Threads with QThread}
\li \l{Synchronizing Threads}
\li \l{Reentrancy and Thread-Safety}
\li \l{Threads and QObjects}
@ -122,7 +121,7 @@
\contentspage Thread Support in Qt
\previouspage Thread Support in Qt
\nextpage Starting Threads with QThread
\nextpage Synchronizing Threads
Qt offers many classes and functions for working with threads. Below are
three different approaches that Qt programmers can use to implement
@ -284,61 +283,11 @@
\endtable
*/
/*!
\page threads-starting.html
\title Starting Threads with QThread
\contentspage Thread Support in Qt
\previouspage Multithreading Technologies in Qt
\nextpage Synchronizing Threads
A QThread instance represents a thread and provides the means to
\l{QThread::start()}{start()} a thread, which will then execute the
reimplementation of QThread::run(). The \c run() implementation is for a
thread what the \c main() entry point is for the application. All code
executed in a call stack that starts in the \c run() function is executed
by the new thread, and the thread finishes when the function returns.
QThread emits signals to indicate that the thread started or finished
executing.
\section1 Creating a Thread
To create a thread, subclass QThread and reimplement its
\l{QThread::run()}{run()} function. For example:
\snippet threads/threads.h 0
\codeline
\snippet threads/threads.cpp 0
\snippet threads/threads.cpp 1
\dots
\snippet threads/threads.cpp 2
\section1 Starting a Thread
Then, create an instance of the thread object and call
QThread::start(). Note that you must create the QApplication (or
QCoreApplication) object before you can create a QThread.
The function will return immediately and the
main thread will continue. The code that appears in the
\l{QThread::run()}{run()} reimplementation will then be executed
in a separate thread.
Creating threads is explained in more detail in the QThread
documentation.
Note that QCoreApplication::exec() must always be called from the
main thread (the thread that executes \c{main()}), not from a
QThread. In GUI applications, the main thread is also called the
GUI thread because it's the only thread that is allowed to
perform GUI-related operations.
*/
/*!
\page threads-synchronizing.html
\title Synchronizing Threads
\previouspage Starting Threads with QThread
\previouspage Multithreading Technologies in Qt
\contentspage Thread Support in Qt
\nextpage Reentrancy and Thread-Safety