diff options
Diffstat (limited to 'examples/qtconcurrent/wordcount/doc')
-rw-r--r-- | examples/qtconcurrent/wordcount/doc/src/qtconcurrent-wordcount.qdoc | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/examples/qtconcurrent/wordcount/doc/src/qtconcurrent-wordcount.qdoc b/examples/qtconcurrent/wordcount/doc/src/qtconcurrent-wordcount.qdoc index 7486340c7b..adefdfdc59 100644 --- a/examples/qtconcurrent/wordcount/doc/src/qtconcurrent-wordcount.qdoc +++ b/examples/qtconcurrent/wordcount/doc/src/qtconcurrent-wordcount.qdoc @@ -1,39 +1,45 @@ -/**************************************************************************** -** -** 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) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example wordcount - \title QtConcurrent Word Count Example - \brief Demonstrates how to use the map-reduce algorithm. + \meta tags {threads, console} + \title Word Count \ingroup qtconcurrentexamples + \examplecategory {Data Processing & I/O} + \brief Demonstrates how to use the map-reduce algorithm. + + The Qt Concurrent \e {Word Count} example demonstrates the use of the + map-reduce algorithm when applied to the problem of counting words in a + collection of files. + + First, the Application starts a QFileDialog to select a starting + path, and then prints the output to the console. + + \include examples-run.qdocinc + + \section1 Comparing the operations + + Compare a single-threaded, sequential approach to counting the words in + the text files to a multithreaded approach with mappedReduced(): + + \dots + \snippet wordcount/main.cpp 1 + \dots + \snippet wordcount/main.cpp 2 + \dots + + The first argument to the \l {QtConcurrent::}{mappedReduced} function is the + container to operate on. The second argument is the mapping function + \c {countWords()}. It is called in parallel by multiple threads. The + third argument is the reducing function \c {reduce()}. It is called + once for each result returned by the mapping function, and generates the + final computation result. - The QtConcurrent Word Count example demonstrates the use of the map-reduce - algorithm when applied to the problem of counting words in a collection - of files. + The function returns a QFuture object of type \c WordCount. Call the + \l {QFuture::}{result} function immediately on this QFuture to block further + execution until the result becomes available. - This is a command-line application. + \note The mapping function must be thread-safe since it is called from + multiple threads. */ |