diff options
Diffstat (limited to 'examples/corelib/threads/doc')
-rw-r--r-- | examples/corelib/threads/doc/src/mandelbrot.qdoc | 24 | ||||
-rw-r--r-- | examples/corelib/threads/doc/src/queuedcustomtype.qdoc | 25 | ||||
-rw-r--r-- | examples/corelib/threads/doc/src/semaphores.qdoc | 14 | ||||
-rw-r--r-- | examples/corelib/threads/doc/src/waitconditions.qdoc | 14 |
4 files changed, 38 insertions, 39 deletions
diff --git a/examples/corelib/threads/doc/src/mandelbrot.qdoc b/examples/corelib/threads/doc/src/mandelbrot.qdoc index e0f703bf3c..6081912e69 100644 --- a/examples/corelib/threads/doc/src/mandelbrot.qdoc +++ b/examples/corelib/threads/doc/src/mandelbrot.qdoc @@ -3,7 +3,8 @@ /*! \example threads/mandelbrot - \title Mandelbrot Example + \examplecategory {Data Processing & I/O} + \title Mandelbrot \ingroup qtconcurrent-mtexamples \brief The Mandelbrot example demonstrates multi-thread programming @@ -13,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 @@ -146,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 @@ -303,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 df904cc438..8d56695c79 100644 --- a/examples/corelib/threads/doc/src/queuedcustomtype.qdoc +++ b/examples/corelib/threads/doc/src/queuedcustomtype.qdoc @@ -3,8 +3,8 @@ /*! \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 @@ -18,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 @@ -127,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 c1d8600c17..f5ff90b014 100644 --- a/examples/corelib/threads/doc/src/semaphores.qdoc +++ b/examples/corelib/threads/doc/src/semaphores.qdoc @@ -3,13 +3,13 @@ /*! \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, @@ -30,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 @@ -39,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 90f911aab3..d46442d079 100644 --- a/examples/corelib/threads/doc/src/waitconditions.qdoc +++ b/examples/corelib/threads/doc/src/waitconditions.qdoc @@ -3,13 +3,13 @@ /*! \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, @@ -30,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 @@ -109,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. |