summaryrefslogtreecommitdiffstats
path: root/examples/corelib/threads/doc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/corelib/threads/doc')
-rw-r--r--examples/corelib/threads/doc/src/mandelbrot.qdoc52
-rw-r--r--examples/corelib/threads/doc/src/queuedcustomtype.qdoc53
-rw-r--r--examples/corelib/threads/doc/src/semaphores.qdoc42
-rw-r--r--examples/corelib/threads/doc/src/waitconditions.qdoc42
4 files changed, 46 insertions, 143 deletions
diff --git a/examples/corelib/threads/doc/src/mandelbrot.qdoc b/examples/corelib/threads/doc/src/mandelbrot.qdoc
index 2b12743538..6081912e69 100644
--- a/examples/corelib/threads/doc/src/mandelbrot.qdoc
+++ b/examples/corelib/threads/doc/src/mandelbrot.qdoc
@@ -1,33 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example threads/mandelbrot
- \title Mandelbrot Example
+ \examplecategory {Data Processing & I/O}
+ \title Mandelbrot
\ingroup qtconcurrent-mtexamples
\brief The Mandelbrot example demonstrates multi-thread programming
@@ -37,17 +14,17 @@
\image mandelbrot-example.png Screenshot of the Mandelbrot example
- The heavy computation here is the Mandelbrot set, probably the
- world's most famous fractal. These days, while sophisticated
- programs such as \l{http://matek.hu/xaos/doku.php}{XaoS} that provide real-time zooming in the
- Mandelbrot set, the standard Mandelbrot algorithm is just slow
- enough for our purposes.
+ The heavy computation here is the Mandelbrot set, probably the world's most
+ famous fractal. These days, while sophisticated programs, such as
+ \l{https://xaos-project.github.io/}{XaoS}, provide real-time zooming in
+ the Mandelbrot set, the standard Mandelbrot algorithm is just slow enough
+ for our purposes.
In real life, the approach described here is applicable to a
large set of problems, including synchronous network I/O and
database access, where the user interface must remain responsive
while some heavy operation is taking place. The \l
- {Blocking Fortune Client Example} shows the same principle at
+ {Blocking Fortune Client} example shows the same principle at
work in a TCP client.
The Mandelbrot application supports zooming and scrolling using
@@ -170,12 +147,12 @@
rendering parameters in local variables. As usual, we protect
accesses to the member variables using the class's mutex. Storing
the member variables in local variables allows us to minimize the
- amout of code that needs to be protected by a mutex. This ensures
+ amount of code that needs to be protected by a mutex. This ensures
that the main thread will never have to block for too long when
it needs to access \c{RenderThread}'s member variables (e.g., in
\c render()).
- The \c forever keyword is, like \c foreach, a Qt pseudo-keyword.
+ The \c forever keyword is a Qt pseudo-keyword.
\snippet threads/mandelbrot/renderthread.cpp 4
\snippet threads/mandelbrot/renderthread.cpp 5
@@ -327,6 +304,11 @@
\snippet threads/mandelbrot/mandelbrotwidget.cpp 13
+ Pinch to zoom has been implemented with QGesture as outlined in
+ \l{Gestures in Widgets and Graphics View}.
+
+ \snippet threads/mandelbrot/mandelbrotwidget.cpp gesture1
+
When the user presses the left mouse button, we store the mouse
pointer position in \c lastDragPos.
diff --git a/examples/corelib/threads/doc/src/queuedcustomtype.qdoc b/examples/corelib/threads/doc/src/queuedcustomtype.qdoc
index 86d5992294..8d56695c79 100644
--- a/examples/corelib/threads/doc/src/queuedcustomtype.qdoc
+++ b/examples/corelib/threads/doc/src/queuedcustomtype.qdoc
@@ -1,34 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example threads/queuedcustomtype
- \title Queued Custom Type Example
- \brief Demonstrates multi-thread programming using Qt.
+ \examplecategory {Data Processing & I/O}
+ \title Queued Custom Type
\ingroup qtconcurrent-mtexamples
\brief The Queued Custom Type example shows how to send custom types between
@@ -42,20 +18,15 @@
\section1 Overview
- In the \l{Custom Type Example}, we showed how to integrate custom types with
- the meta-object system, enabling them to be stored in QVariant objects, written
- out in debugging information and used in signal-slot communication.
-
- In this example, we create a new value class, \c Block, and register it
- with the meta-object system to enable us to send instances of it between
- threads using queued signals and slots.
+ In this example, we create a value class, \c Block, and register it with
+ the meta-object system to enable us to send instances of it between threads
+ using queued signals and slots.
\section1 The Block Class
- The \c Block class is similar to the \c Message class described in the
- \l{Custom Type Example}. It provides the default constructor, copy
- constructor and destructor in the public section of the class that the
- meta-object system requires. It describes a colored rectangle.
+ The \c Block class provides the default constructor, copy constructor, and
+ a destructor in the public section of the class as required by the
+ meta-object system. The class describes a colored rectangle.
\snippet threads/queuedcustomtype/block.h custom type definition and meta-type declaration
@@ -151,9 +122,7 @@
This example showed how a custom type can be registered with the
meta-object system so that it can be used with signal-slot connections
- between threads. For ordinary communication involving direct signals and
- slots, it is enough to simply declare the type in the way described in the
- \l{Custom Type Example}.
+ between threads.
In practice, both the Q_DECLARE_METATYPE() macro and the qRegisterMetaType()
template function can be used to register custom types, but
diff --git a/examples/corelib/threads/doc/src/semaphores.qdoc b/examples/corelib/threads/doc/src/semaphores.qdoc
index 5293e80c0e..f5ff90b014 100644
--- a/examples/corelib/threads/doc/src/semaphores.qdoc
+++ b/examples/corelib/threads/doc/src/semaphores.qdoc
@@ -1,39 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example threads/semaphores
- \title Semaphores Example
- \brief Demonstrates multi-thread programming using Qt.
+ \examplecategory {Data Processing & I/O}
+ \title Producer and Consumer using Semaphores
\ingroup qtconcurrent-mtexamples
- \brief The Semaphores example shows how to use QSemaphore to control
- access to a circular buffer shared by a producer thread and a
- consumer thread.
+ \brief The Producer and Consumer using Semaphores example shows how
+ to use QSemaphore to control access to a circular buffer shared
+ by a producer thread and a consumer thread.
The producer writes data to the buffer until it reaches the end
of the buffer, at which point it restarts from the beginning,
@@ -54,7 +30,7 @@
An alternative to using QSemaphore to solve the producer-consumer
problem is to use QWaitCondition and QMutex. This is what the
- \l{Wait Conditions Example} does.
+ \l{Producer and Consumer using Wait Conditions} example does.
\section1 Global Variables
@@ -63,7 +39,7 @@
\snippet threads/semaphores/semaphores.cpp 0
- \c DataSize is the amout of data that the producer will generate.
+ \c DataSize is the amount of data that the producer will generate.
To keep the example as simple as possible, we make it a constant.
\c BufferSize is the size of the circular buffer. It is less than
\c DataSize, meaning that at some point the producer will reach
diff --git a/examples/corelib/threads/doc/src/waitconditions.qdoc b/examples/corelib/threads/doc/src/waitconditions.qdoc
index cfac460345..d46442d079 100644
--- a/examples/corelib/threads/doc/src/waitconditions.qdoc
+++ b/examples/corelib/threads/doc/src/waitconditions.qdoc
@@ -1,39 +1,15 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example threads/waitconditions
- \title Wait Conditions Example
- \brief Demonstrates multi-thread programming using Qt.
+ \examplecategory {Data Processing & I/O}
+ \title Producer and Consumer using Wait Conditions
\ingroup qtconcurrent-mtexamples
- \brief The Wait Conditions example shows how to use QWaitCondition and
- QMutex to control access to a circular buffer shared by a
- producer thread and a consumer thread.
+ \brief The Producer and Consumer using Wait Conditions example shows
+ how to use QWaitCondition and QMutex to control access to a circular
+ buffer shared by a producer thread and a consumer thread.
The producer writes data to the buffer until it reaches the end
of the buffer, at which point it restarts from the beginning,
@@ -54,7 +30,7 @@
An alternative to using QWaitCondition and QMutex to solve the
producer-consumer problem is to use QSemaphore. This is what the
- \l{Semaphores Example} does.
+ \l{Producer and Consumer using Semaphores} example does.
\section1 Global Variables
@@ -133,7 +109,7 @@
thread is the only one that can do anything; the consumer is
blocked waiting for the \c bufferNotEmpty condition to be
signalled (\c numUsedBytes is 0). Once the producer has put one
- byte in the buffer, \c numUsedBytes is \c BufferSize - 1 and the
+ byte in the buffer, \c numUsedBytes is strictly greater than 0, and the
\c bufferNotEmpty condition is signalled. At that point, two
things can happen: Either the consumer thread takes over and
reads that byte, or the producer gets to produce a second byte.