Doc: Modularize QtConcurrent documentation.
This change moves the snippets and images to the modularized directories. Change-Id: If52f69c0f8bb4d2df4ee46f5524a82047ec214de Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
This commit is contained in:
parent
a409cebe3d
commit
4548022ee2
92
src/concurrent/doc/qtconcurrent.qdocconf
Normal file
92
src/concurrent/doc/qtconcurrent.qdocconf
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
include(../../../doc/global/qt-cpp-ignore.qdocconf)
|
||||||
|
|
||||||
|
project = QtConcurrent
|
||||||
|
description = Qt Concurrent Reference Documentation
|
||||||
|
url = http://qt-project.org/doc/qt-5.0/qtconcurrent
|
||||||
|
version = 5.0.0
|
||||||
|
|
||||||
|
sourceencoding = UTF-8
|
||||||
|
outputencoding = UTF-8
|
||||||
|
naturallanguage = en_US
|
||||||
|
qhp.projects = QtConcurrent
|
||||||
|
|
||||||
|
qhp.QtConcurrent.file = qtconcurrent.qhp
|
||||||
|
qhp.QtConcurrent.namespace = org.qt-project.qtconcurrent.500
|
||||||
|
qhp.QtConcurrent.virtualFolder = qdoc
|
||||||
|
qhp.QtConcurrent.indexTitle = Qt Concurrent Reference Documentation
|
||||||
|
qhp.QtConcurrent.indexRoot =
|
||||||
|
|
||||||
|
qhp.QtConcurrent.filterAttributes = qtconcurrent 5.0.0 qtrefdoc
|
||||||
|
qhp.QtConcurrent.customFilters.Qt.name = QtConcurrent 5.0.0
|
||||||
|
qhp.QtConcurrent.customFilters.Qt.filterAttributes = qtconcurrent 5.0.0
|
||||||
|
qhp.QtConcurrent.subprojects = classes overviews examples
|
||||||
|
qhp.QtConcurrent.subprojects.classes.title = Classes
|
||||||
|
qhp.QtConcurrent.subprojects.classes.indexTitle = Qt Concurrent's Classes
|
||||||
|
qhp.QtConcurrent.subprojects.classes.selectors = class fake:headerfile
|
||||||
|
qhp.QtConcurrent.subprojects.classes.sortPages = true
|
||||||
|
qhp.QtConcurrent.subprojects.overviews.title = Overviews
|
||||||
|
qhp.QtConcurrent.subprojects.overviews.indexTitle = All Overviews and HOWTOs
|
||||||
|
qhp.QtConcurrent.subprojects.overviews.selectors = fake:page,group,module
|
||||||
|
qhp.QtConcurrent.subprojects.examples.title = Qt Concurrent Examples
|
||||||
|
qhp.QtConcurrent.subprojects.examples.indexTitle = Qt Concurrent Examples
|
||||||
|
qhp.QtConcurrent.subprojects.examples.selectors = fake:example
|
||||||
|
|
||||||
|
dita.metadata.default.author = Qt Project
|
||||||
|
dita.metadata.default.permissions = all
|
||||||
|
dita.metadata.default.publisher = Qt Project
|
||||||
|
dita.metadata.default.copyryear = 2012
|
||||||
|
dita.metadata.default.copyrholder = Nokia
|
||||||
|
dita.metadata.default.audience = programmer
|
||||||
|
|
||||||
|
sources.fileextensions = "*.c++ *.cc *.cpp *.cxx *.mm *.qml *.qdoc"
|
||||||
|
headers.fileextensions = "*.ch *.h *.h++ *.hh *.hpp *.hxx"
|
||||||
|
|
||||||
|
examples.fileextensions = "*.cpp *.h *.js *.xq *.svg *.xml *.ui *.qhp *.qhcp *.qml *.css"
|
||||||
|
examples.imageextensions = "*.png"
|
||||||
|
|
||||||
|
outputdir = ../../../doc/qtconcurrent
|
||||||
|
tagfile = ../../../doc/qtconcurrent/qtconcurrent.tags
|
||||||
|
|
||||||
|
HTML.generatemacrefs = "true"
|
||||||
|
HTML.nobreadcrumbs = "true"
|
||||||
|
|
||||||
|
HTML.templatedir = .
|
||||||
|
|
||||||
|
HTML.stylesheets = ../../../doc/global/style/offline.css
|
||||||
|
|
||||||
|
HTML.headerstyles = \
|
||||||
|
" <link rel=\"stylesheet\" type=\"text/css\" href=\"style/offline.css\" />\n"
|
||||||
|
|
||||||
|
HTML.endheader = \
|
||||||
|
"</head>\n" \
|
||||||
|
|
||||||
|
defines = Q_QDOC \
|
||||||
|
QT_.*_SUPPORT \
|
||||||
|
QT_.*_LIB \
|
||||||
|
QT_COMPAT \
|
||||||
|
QT_KEYPAD_NAVIGATION \
|
||||||
|
QT_NO_EGL \
|
||||||
|
Q_WS_.* \
|
||||||
|
Q_OS_.* \
|
||||||
|
Q_BYTE_ORDER \
|
||||||
|
QT_DEPRECATED \
|
||||||
|
QT_DEPRECATED_* \
|
||||||
|
Q_NO_USING_KEYWORD \
|
||||||
|
__cplusplus \
|
||||||
|
Q_COMPILER_INITIALIZER_LISTS
|
||||||
|
|
||||||
|
versionsym = QT_VERSION_STR
|
||||||
|
|
||||||
|
codeindent = 1
|
||||||
|
|
||||||
|
depends += qtcore
|
||||||
|
|
||||||
|
headerdirs += ..
|
||||||
|
|
||||||
|
sourcedirs += ..
|
||||||
|
|
||||||
|
exampledirs += ../../../examples \
|
||||||
|
../ \
|
||||||
|
snippets
|
||||||
|
|
||||||
|
imagedirs += images
|
@ -374,7 +374,7 @@
|
|||||||
QFuture::constBegin() or QFuture::constEnd() before you start iterating.
|
QFuture::constBegin() or QFuture::constEnd() before you start iterating.
|
||||||
Here's a typical loop that prints all the results available in a future:
|
Here's a typical loop that prints all the results available in a future:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp 0
|
\snippet code/src_concurrent_qfuture.cpp 0
|
||||||
|
|
||||||
\sa QFutureIterator, QFuture
|
\sa QFutureIterator, QFuture
|
||||||
*/
|
*/
|
||||||
@ -555,7 +555,7 @@
|
|||||||
list (i.e. before the first result). Here's how to iterate over all the
|
list (i.e. before the first result). Here's how to iterate over all the
|
||||||
results sequentially:
|
results sequentially:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp 1
|
\snippet code/src_concurrent_qfuture.cpp 1
|
||||||
|
|
||||||
The next() function returns the next result (waiting for it to become
|
The next() function returns the next result (waiting for it to become
|
||||||
available, if necessary) from the future and advances the iterator. Unlike
|
available, if necessary) from the future and advances the iterator. Unlike
|
||||||
@ -570,7 +570,7 @@
|
|||||||
|
|
||||||
Here's how to iterate over the elements in reverse order:
|
Here's how to iterate over the elements in reverse order:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qfuture.cpp 2
|
\snippet code/src_concurrent_qfuture.cpp 2
|
||||||
|
|
||||||
If you want to find all occurrences of a particular value, use findNext()
|
If you want to find all occurrences of a particular value, use findNext()
|
||||||
or findPrevious() in a loop.
|
or findPrevious() in a loop.
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
an easy way to ensure that all futures have finished before returning from
|
an easy way to ensure that all futures have finished before returning from
|
||||||
a function:
|
a function:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qfuturesynchronizer.cpp 0
|
\snippet code/src_concurrent_qfuturesynchronizer.cpp 0
|
||||||
|
|
||||||
The behavior of waitForFinished() can be changed using the
|
The behavior of waitForFinished() can be changed using the
|
||||||
setCancelOnWait() function. Calling setCancelOnWait(true) will cause
|
setCancelOnWait() function. Calling setCancelOnWait(true) will cause
|
||||||
|
@ -86,7 +86,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
Example: Starting a computation and getting a slot callback when it's
|
Example: Starting a computation and getting a slot callback when it's
|
||||||
finished:
|
finished:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qfuturewatcher.cpp 0
|
\snippet code/src_concurrent_qfuturewatcher.cpp 0
|
||||||
|
|
||||||
Be aware that not all asynchronous computations can be canceled or paused.
|
Be aware that not all asynchronous computations can be canceled or paused.
|
||||||
For example, the future returned by QtConcurrent::run() cannot be
|
For example, the future returned by QtConcurrent::run() cannot be
|
||||||
|
@ -56,12 +56,12 @@ QT_BEGIN_NAMESPACE
|
|||||||
boundaries, provided that the exception inherit from QtConcurrent::Exception
|
boundaries, provided that the exception inherit from QtConcurrent::Exception
|
||||||
and implement two helper functions:
|
and implement two helper functions:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp 0
|
\snippet code/src_concurrent_qtconcurrentexception.cpp 0
|
||||||
|
|
||||||
QtConcurrent::Exception subclasses must be thrown by value and
|
QtConcurrent::Exception subclasses must be thrown by value and
|
||||||
caught by reference:
|
caught by reference:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp 1
|
\snippet code/src_concurrent_qtconcurrentexception.cpp 1
|
||||||
|
|
||||||
If you throw an exception that is not a subclass of QtConcurrent::Exception,
|
If you throw an exception that is not a subclass of QtConcurrent::Exception,
|
||||||
the Qt Concurrent functions will throw a QtConcurrent::UnhandledException
|
the Qt Concurrent functions will throw a QtConcurrent::UnhandledException
|
||||||
@ -80,14 +80,14 @@ QT_BEGIN_NAMESPACE
|
|||||||
\fn QtConcurrent::Exception::raise() const
|
\fn QtConcurrent::Exception::raise() const
|
||||||
In your QtConcurrent::Exception subclass, reimplement raise() like this:
|
In your QtConcurrent::Exception subclass, reimplement raise() like this:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp 2
|
\snippet code/src_concurrent_qtconcurrentexception.cpp 2
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn QtConcurrent::Exception::clone() const
|
\fn QtConcurrent::Exception::clone() const
|
||||||
In your QtConcurrent::Exception subclass, reimplement clone() like this:
|
In your QtConcurrent::Exception subclass, reimplement clone() like this:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentexception.cpp 3
|
\snippet code/src_concurrent_qtconcurrentexception.cpp 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
result instead of a QFuture. You use them in the same way as the
|
result instead of a QFuture. You use them in the same way as the
|
||||||
asynchronous variants.
|
asynchronous variants.
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 6
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 6
|
||||||
|
|
||||||
Note that the result types above are not QFuture objects, but real result
|
Note that the result types above are not QFuture objects, but real result
|
||||||
types (in this case, QStringList and QSet<QString>).
|
types (in this case, QStringList and QSet<QString>).
|
||||||
@ -73,7 +73,7 @@
|
|||||||
|
|
||||||
The filter function must be of the form:
|
The filter function must be of the form:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 0
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 0
|
||||||
|
|
||||||
T must match the type stored in the sequence. The function returns true if
|
T must match the type stored in the sequence. The function returns true if
|
||||||
the item should be kept, false if it should be discarded.
|
the item should be kept, false if it should be discarded.
|
||||||
@ -81,7 +81,7 @@
|
|||||||
This example shows how to keep strings that are all lower-case from a
|
This example shows how to keep strings that are all lower-case from a
|
||||||
QStringList:
|
QStringList:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 1
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 1
|
||||||
|
|
||||||
The results of the filter are made available through QFuture. See the
|
The results of the filter are made available through QFuture. See the
|
||||||
QFuture and QFutureWatcher documentation for more information on how to
|
QFuture and QFutureWatcher documentation for more information on how to
|
||||||
@ -89,7 +89,7 @@
|
|||||||
|
|
||||||
If you want to modify a sequence in-place, use QtConcurrent::filter():
|
If you want to modify a sequence in-place, use QtConcurrent::filter():
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 2
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 2
|
||||||
|
|
||||||
Since the sequence is modified in place, QtConcurrent::filter() does not
|
Since the sequence is modified in place, QtConcurrent::filter() does not
|
||||||
return any results via QFuture. However, you can still use QFuture and
|
return any results via QFuture. However, you can still use QFuture and
|
||||||
@ -103,7 +103,7 @@
|
|||||||
|
|
||||||
The reduce function must be of the form:
|
The reduce function must be of the form:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 3
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 3
|
||||||
|
|
||||||
T is the type of the final result, U is the type of items being filtered.
|
T is the type of the final result, U is the type of items being filtered.
|
||||||
Note that the return value and return type of the reduce function are not
|
Note that the return value and return type of the reduce function are not
|
||||||
@ -111,7 +111,7 @@
|
|||||||
|
|
||||||
Call QtConcurrent::filteredReduced() like this:
|
Call QtConcurrent::filteredReduced() like this:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 4
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 4
|
||||||
|
|
||||||
The reduce function will be called once for each result kept by the filter
|
The reduce function will be called once for each result kept by the filter
|
||||||
function, and should merge the \e{intermediate} into the \e{result}
|
function, and should merge the \e{intermediate} into the \e{result}
|
||||||
@ -128,7 +128,7 @@
|
|||||||
instead of a sequence. You use them in the same way as the sequence
|
instead of a sequence. You use them in the same way as the sequence
|
||||||
variants:
|
variants:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 5
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 5
|
||||||
|
|
||||||
|
|
||||||
\section2 Using Member Functions
|
\section2 Using Member Functions
|
||||||
@ -137,12 +137,12 @@
|
|||||||
QtConcurrent::filteredReduced() accept pointers to member functions.
|
QtConcurrent::filteredReduced() accept pointers to member functions.
|
||||||
The member function class type must match the type stored in the sequence:
|
The member function class type must match the type stored in the sequence:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 7
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 7
|
||||||
|
|
||||||
Note that when using QtConcurrent::filteredReduced(), you can mix the use of
|
Note that when using QtConcurrent::filteredReduced(), you can mix the use of
|
||||||
normal and member functions freely:
|
normal and member functions freely:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 8
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 8
|
||||||
|
|
||||||
\section2 Using Function Objects
|
\section2 Using Function Objects
|
||||||
|
|
||||||
@ -151,7 +151,7 @@
|
|||||||
add state to a function call. The result_type typedef must define the
|
add state to a function call. The result_type typedef must define the
|
||||||
result type of the function call operator:
|
result type of the function call operator:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 13
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 13
|
||||||
|
|
||||||
\section2 Using Bound Function Arguments
|
\section2 Using Bound Function Arguments
|
||||||
|
|
||||||
@ -167,7 +167,7 @@
|
|||||||
|
|
||||||
As an example, we use QString::contains():
|
As an example, we use QString::contains():
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 9
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 9
|
||||||
|
|
||||||
QString::contains() takes 2 arguments (including the "this" pointer) and
|
QString::contains() takes 2 arguments (including the "this" pointer) and
|
||||||
can't be used with QtConcurrent::filtered() directly, because
|
can't be used with QtConcurrent::filtered() directly, because
|
||||||
@ -175,17 +175,17 @@
|
|||||||
use QString::contains() with QtConcurrent::filtered() we have to provide a
|
use QString::contains() with QtConcurrent::filtered() we have to provide a
|
||||||
value for the \e regexp argument:
|
value for the \e regexp argument:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 10
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 10
|
||||||
|
|
||||||
The return value from boost::bind() is a function object (functor) with
|
The return value from boost::bind() is a function object (functor) with
|
||||||
the following signature:
|
the following signature:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 11
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 11
|
||||||
|
|
||||||
This matches what QtConcurrent::filtered() expects, and the complete
|
This matches what QtConcurrent::filtered() expects, and the complete
|
||||||
example becomes:
|
example becomes:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentfilter.cpp 12
|
\snippet code/src_concurrent_qtconcurrentfilter.cpp 12
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -95,7 +95,7 @@
|
|||||||
the final result instead of a QFuture. You use them in the same
|
the final result instead of a QFuture. You use them in the same
|
||||||
way as the asynchronous variants.
|
way as the asynchronous variants.
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 7
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 7
|
||||||
|
|
||||||
Note that the result types above are not QFuture objects, but real result
|
Note that the result types above are not QFuture objects, but real result
|
||||||
types (in this case, QList<QImage> and QImage).
|
types (in this case, QList<QImage> and QImage).
|
||||||
@ -108,7 +108,7 @@
|
|||||||
|
|
||||||
The map function must be of the form:
|
The map function must be of the form:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 0
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 0
|
||||||
|
|
||||||
T and U can be any type (and they can even be the same type), but T must
|
T and U can be any type (and they can even be the same type), but T must
|
||||||
match the type stored in the sequence. The function returns the modified
|
match the type stored in the sequence. The function returns the modified
|
||||||
@ -117,7 +117,7 @@
|
|||||||
This example shows how to apply a scale function to all the items
|
This example shows how to apply a scale function to all the items
|
||||||
in a sequence:
|
in a sequence:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 1
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 1
|
||||||
|
|
||||||
The results of the map are made available through QFuture. See the
|
The results of the map are made available through QFuture. See the
|
||||||
QFuture and QFutureWatcher documentation for more information on how to
|
QFuture and QFutureWatcher documentation for more information on how to
|
||||||
@ -126,14 +126,14 @@
|
|||||||
If you want to modify a sequence in-place, use QtConcurrent::map(). The
|
If you want to modify a sequence in-place, use QtConcurrent::map(). The
|
||||||
map function must then be of the form:
|
map function must then be of the form:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 2
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 2
|
||||||
|
|
||||||
Note that the return value and return type of the map function are not
|
Note that the return value and return type of the map function are not
|
||||||
used.
|
used.
|
||||||
|
|
||||||
Using QtConcurrent::map() is similar to using QtConcurrent::mapped():
|
Using QtConcurrent::map() is similar to using QtConcurrent::mapped():
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 3
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 3
|
||||||
|
|
||||||
Since the sequence is modified in place, QtConcurrent::map() does not
|
Since the sequence is modified in place, QtConcurrent::map() does not
|
||||||
return any results via QFuture. However, you can still use QFuture and
|
return any results via QFuture. However, you can still use QFuture and
|
||||||
@ -147,7 +147,7 @@
|
|||||||
|
|
||||||
The reduce function must be of the form:
|
The reduce function must be of the form:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 4
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 4
|
||||||
|
|
||||||
T is the type of the final result, U is the return type of the map
|
T is the type of the final result, U is the return type of the map
|
||||||
function. Note that the return value and return type of the reduce
|
function. Note that the return value and return type of the reduce
|
||||||
@ -155,7 +155,7 @@
|
|||||||
|
|
||||||
Call QtConcurrent::mappedReduced() like this:
|
Call QtConcurrent::mappedReduced() like this:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 5
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 5
|
||||||
|
|
||||||
The reduce function will be called once for each result returned by the map
|
The reduce function will be called once for each result returned by the map
|
||||||
function, and should merge the \e{intermediate} into the \e{result}
|
function, and should merge the \e{intermediate} into the \e{result}
|
||||||
@ -175,7 +175,7 @@
|
|||||||
instead of a sequence. You use them in the same way as the sequence
|
instead of a sequence. You use them in the same way as the sequence
|
||||||
variants:
|
variants:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 6
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 6
|
||||||
|
|
||||||
\section2 Blocking Variants
|
\section2 Blocking Variants
|
||||||
|
|
||||||
@ -183,7 +183,7 @@
|
|||||||
the final result instead of a QFuture. You use them in the same
|
the final result instead of a QFuture. You use them in the same
|
||||||
way as the asynchronous variants.
|
way as the asynchronous variants.
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 7
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 7
|
||||||
|
|
||||||
Note that the result types above are not QFuture objects, but real result
|
Note that the result types above are not QFuture objects, but real result
|
||||||
types (in this case, QList<QImage> and QImage).
|
types (in this case, QList<QImage> and QImage).
|
||||||
@ -194,12 +194,12 @@
|
|||||||
QtConcurrent::mappedReduced() accept pointers to member functions.
|
QtConcurrent::mappedReduced() accept pointers to member functions.
|
||||||
The member function class type must match the type stored in the sequence:
|
The member function class type must match the type stored in the sequence:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 8
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 8
|
||||||
|
|
||||||
Note that when using QtConcurrent::mappedReduced(), you can mix the use of
|
Note that when using QtConcurrent::mappedReduced(), you can mix the use of
|
||||||
normal and member functions freely:
|
normal and member functions freely:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 9
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 9
|
||||||
|
|
||||||
\section2 Using Function Objects
|
\section2 Using Function Objects
|
||||||
|
|
||||||
@ -208,7 +208,7 @@
|
|||||||
add state to a function call. The result_type typedef must define the
|
add state to a function call. The result_type typedef must define the
|
||||||
result type of the function call operator:
|
result type of the function call operator:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 14
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 14
|
||||||
|
|
||||||
\section2 Using Bound Function Arguments
|
\section2 Using Bound Function Arguments
|
||||||
|
|
||||||
@ -224,7 +224,7 @@
|
|||||||
|
|
||||||
As an example, we'll use QImage::scaledToWidth():
|
As an example, we'll use QImage::scaledToWidth():
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 10
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 10
|
||||||
|
|
||||||
scaledToWidth takes three arguments (including the "this" pointer) and
|
scaledToWidth takes three arguments (including the "this" pointer) and
|
||||||
can't be used with QtConcurrent::mapped() directly, because
|
can't be used with QtConcurrent::mapped() directly, because
|
||||||
@ -232,17 +232,17 @@
|
|||||||
QImage::scaledToWidth() with QtConcurrent::mapped() we have to provide a
|
QImage::scaledToWidth() with QtConcurrent::mapped() we have to provide a
|
||||||
value for the \e{width} and the \e{transformation mode}:
|
value for the \e{width} and the \e{transformation mode}:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 11
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 11
|
||||||
|
|
||||||
The return value from boost::bind() is a function object (functor) with
|
The return value from boost::bind() is a function object (functor) with
|
||||||
the following signature:
|
the following signature:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 12
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 12
|
||||||
|
|
||||||
This matches what QtConcurrent::mapped() expects, and the complete example
|
This matches what QtConcurrent::mapped() expects, and the complete example
|
||||||
becomes:
|
becomes:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentmap.cpp 13
|
\snippet code/src_concurrent_qtconcurrentmap.cpp 13
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
To run a function in another thread, use QtConcurrent::run():
|
To run a function in another thread, use QtConcurrent::run():
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp 0
|
\snippet code/src_concurrent_qtconcurrentrun.cpp 0
|
||||||
|
|
||||||
This will run \e aFunction in a separate thread obtained from the default
|
This will run \e aFunction in a separate thread obtained from the default
|
||||||
QThreadPool. You can use the QFuture and QFutureWatcher classes to monitor
|
QThreadPool. You can use the QFuture and QFutureWatcher classes to monitor
|
||||||
@ -68,7 +68,7 @@
|
|||||||
Passing arguments to the function is done by adding them to the
|
Passing arguments to the function is done by adding them to the
|
||||||
QtConcurrent::run() call immediately after the function name. For example:
|
QtConcurrent::run() call immediately after the function name. For example:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp 1
|
\snippet code/src_concurrent_qtconcurrentrun.cpp 1
|
||||||
|
|
||||||
A copy of each argument is made at the point where QtConcurrent::run() is
|
A copy of each argument is made at the point where QtConcurrent::run() is
|
||||||
called, and these values are passed to the thread when it begins executing
|
called, and these values are passed to the thread when it begins executing
|
||||||
@ -79,11 +79,11 @@
|
|||||||
|
|
||||||
Any return value from the function is available via QFuture:
|
Any return value from the function is available via QFuture:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp 2
|
\snippet code/src_concurrent_qtconcurrentrun.cpp 2
|
||||||
|
|
||||||
As documented above, passing arguments is done like this:
|
As documented above, passing arguments is done like this:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp 3
|
\snippet code/src_concurrent_qtconcurrentrun.cpp 3
|
||||||
|
|
||||||
Note that the QFuture::result() function blocks and waits for the result
|
Note that the QFuture::result() function blocks and waits for the result
|
||||||
to become available. Use QFutureWatcher to get notification when the
|
to become available. Use QFutureWatcher to get notification when the
|
||||||
@ -102,11 +102,11 @@
|
|||||||
For example, calling QByteArray::split() (a const member function) in a
|
For example, calling QByteArray::split() (a const member function) in a
|
||||||
separate thread is done like this:
|
separate thread is done like this:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp 4
|
\snippet code/src_concurrent_qtconcurrentrun.cpp 4
|
||||||
|
|
||||||
Calling a non-const member function is done like this:
|
Calling a non-const member function is done like this:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp 5
|
\snippet code/src_concurrent_qtconcurrentrun.cpp 5
|
||||||
|
|
||||||
\section2 Using Bound Function Arguments
|
\section2 Using Bound Function Arguments
|
||||||
|
|
||||||
@ -131,7 +131,7 @@
|
|||||||
|
|
||||||
Calling a bound function is done like this:
|
Calling a bound function is done like this:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/src_corelib_concurrent_qtconcurrentrun.cpp 6
|
\snippet code/src_concurrent_qtconcurrentrun.cpp 6
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
Reference in New Issue
Block a user