1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5/*!
6 \namespace QtConcurrent
7 \inmodule QtConcurrent
8 \since 4.4
9 \brief The QtConcurrent namespace provides high-level APIs that make it
10 possible to write multi-threaded programs without using low-level
11 threading primitives.
12
13 See the \l {Qt Concurrent} module documentation for an overview of available
14 functions, or see below for detailed information on each function.
15
16 \inheaderfile QtConcurrent
17 \ingroup thread
18*/
19
20/*!
21 \enum QtConcurrent::ReduceQueueLimits
22 \internal
23 */
24
25/*!
26 \class QtConcurrent::ReduceKernel
27 \inmodule QtConcurrent
28 \internal
29*/
30
31/*!
32 \class QtConcurrent::SequenceHolder2
33 \inmodule QtConcurrent
34 \internal
35*/
36
37/*!
38 \class QtConcurrent::MapKernel
39 \inmodule QtConcurrent
40 \internal
41*/
42
43/*!
44 \class QtConcurrent::MappedReducedKernel
45 \inmodule QtConcurrent
46 \internal
47*/
48
49/*!
50 \class QtConcurrent::MappedEachKernel
51 \inmodule QtConcurrent
52 \internal
53*/
54
55/*!
56 \class QtConcurrent::SequenceHolder1
57 \inmodule QtConcurrent
58 \internal
59*/
60
61/*!
62 \fn [qtconcurrentmapkernel-1] ThreadEngineStarter<void> QtConcurrent::startMap(Iterator begin, Iterator end, Functor &&functor)
63 \internal
64*/
65
66/*!
67 \fn [qtconcurrentmapkernel-2] ThreadEngineStarter<T> QtConcurrent::startMapped(Iterator begin, Iterator end, Functor &&functor)
68 \internal
69*/
70
71/*!
72 \fn [qtconcurrentmapkernel-3] ThreadEngineStarter<T> QtConcurrent::startMapped(Sequence &&sequence, Functor &&functor)
73 \internal
74*/
75
76/*!
77 \fn [qtconcurrentmapkernel-4] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Sequence &&sequence, MapFunctor &&mapFunctor, ReduceFunctor &&reduceFunctor, ReduceOptions options)
78 \internal
79*/
80
81/*!
82 \fn [qtconcurrentmapkernel-5] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunctor, ReduceFunctor &&reduceFunctor, ReduceOptions options)
83 \internal
84*/
85
86/*!
87 \fn [qtconcurrentmapkernel-6] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Sequence &&sequence, MapFunctor &&mapFunctor, ReduceFunctor &&reduceFunctor, ResultType &&initialValue, ReduceOptions options)
88 \internal
89*/
90
91/*!
92 \fn [qtconcurrentmapkernel-7] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunctor, ReduceFunctor &&reduceFunctor, ResultType &&initialValue, ReduceOptions options)
93 \internal
94*/
95
96/*!
97 \enum QtConcurrent::ReduceOption
98 This enum specifies the order of which results from the map or filter
99 function are passed to the reduce function.
100
101 \value UnorderedReduce Reduction is done in an arbitrary order.
102 \value OrderedReduce Reduction is done in the order of the
103 original sequence.
104 \value SequentialReduce Reduction is done sequentially: only one
105 thread will enter the reduce function at a time. (Parallel reduction
106 might be supported in a future version of Qt Concurrent.)
107*/
108
109/*!
110 \page qtconcurrentmap.html
111 \title Concurrent Map and Map-Reduce
112 \brief Transforming values from a sequence and combining them, all in parallel.
113 \ingroup thread
114
115 The QtConcurrent::map(), QtConcurrent::mapped() and
116 QtConcurrent::mappedReduced() functions run computations in parallel on
117 the items in a sequence such as a QList. QtConcurrent::map()
118 modifies a sequence in-place, QtConcurrent::mapped() returns a new
119 sequence containing the modified content, and QtConcurrent::mappedReduced()
120 returns a single result.
121
122 These functions are part of the \l {Qt Concurrent} framework.
123
124 Each of the above functions has a blocking variant that returns
125 the final result instead of a QFuture. You use them in the same
126 way as the asynchronous variants.
127
128 \snippet code/src_concurrent_qtconcurrentmap.cpp 7
129
130 Note that the result types above are not QFuture objects, but real result
131 types (in this case, QList<QImage> and QImage).
132
133 \section1 Concurrent Map
134
135 QtConcurrent::mapped() takes an input sequence and a map function. This map
136 function is then called for each item in the sequence, and a new sequence
137 containing the return values from the map function is returned.
138
139 The map function must be of the form:
140
141 \snippet code/src_concurrent_qtconcurrentmap.cpp 0
142
143 T and U can be any type (and they can even be the same type), but T must
144 match the type stored in the sequence. The function returns the modified
145 or \e mapped content.
146
147 This example shows how to apply a scale function to all the items
148 in a sequence:
149
150 \snippet code/src_concurrent_qtconcurrentmap.cpp 1
151
152 The results of the map are made available through QFuture. See the
153 QFuture and QFutureWatcher documentation for more information on how to
154 use QFuture in your applications.
155
156 If you want to modify a sequence in-place, use QtConcurrent::map(). The
157 map function must then be of the form:
158
159 \snippet code/src_concurrent_qtconcurrentmap.cpp 2
160
161 Note that the return value and return type of the map function are not
162 used.
163
164 Using QtConcurrent::map() is similar to using QtConcurrent::mapped():
165
166 \snippet code/src_concurrent_qtconcurrentmap.cpp 3
167
168 Since the sequence is modified in place, QtConcurrent::map() does not
169 return any results via QFuture. However, you can still use QFuture and
170 QFutureWatcher to monitor the status of the map.
171
172 \section2 Concurrent Mapped and Continuations
173
174 The result of QtConcurrent::mapped() call is a QFuture that contains
175 multiple results. When attaching a \c {.then()} continuation to such
176 QFuture, make sure to use a continuation that takes QFuture as a parameter,
177 otherwise only the first result will be processed:
178
179 \snippet code/src_concurrent_qtconcurrentmap.cpp 18
180
181 In this example \c {badFuture} will only print a single result, while
182 \c {goodFuture} will print all results.
183
184 \section1 Concurrent Map-Reduce
185
186 QtConcurrent::mappedReduced() is similar to QtConcurrent::mapped(), but
187 instead of returning a sequence with the new results, the results are
188 combined into a single value using a reduce function.
189
190 The reduce function must be of the form:
191
192 \snippet code/src_concurrent_qtconcurrentmap.cpp 4
193
194 T is the type of the final result, U is the return type of the map
195 function. Note that the return value and return type of the reduce
196 function are not used.
197
198 Call QtConcurrent::mappedReduced() like this:
199
200 \snippet code/src_concurrent_qtconcurrentmap.cpp 5
201
202 The reduce function will be called once for each result returned by the map
203 function, and should merge the \e{intermediate} into the \e{result}
204 variable. QtConcurrent::mappedReduced() guarantees that only one thread
205 will call reduce at a time, so using a mutex to lock the result variable
206 is not necessary. The QtConcurrent::ReduceOptions enum provides a way to
207 control the order in which the reduction is done. If
208 QtConcurrent::UnorderedReduce is used (the default), the order is
209 undefined, while QtConcurrent::OrderedReduce ensures that the reduction
210 is done in the order of the original sequence.
211
212 \section1 Additional API Features
213
214 \section2 Using Iterators instead of Sequence
215
216 Each of the above functions has a variant that takes an iterator range
217 instead of a sequence. You use them in the same way as the sequence
218 variants:
219
220 \snippet code/src_concurrent_qtconcurrentmap.cpp 6
221
222 \section2 Blocking Variants
223
224 Each of the above functions has a blocking variant that returns
225 the final result instead of a QFuture. You use them in the same
226 way as the asynchronous variants.
227
228 \snippet code/src_concurrent_qtconcurrentmap.cpp 7
229
230 Note that the result types above are not QFuture objects, but real result
231 types (in this case, QList<QImage> and QImage).
232
233 \section2 Using Member Functions
234
235 QtConcurrent::map(), QtConcurrent::mapped(), and
236 QtConcurrent::mappedReduced() accept pointers to member functions.
237 The member function class type must match the type stored in the sequence:
238
239 \snippet code/src_concurrent_qtconcurrentmap.cpp 8
240
241 Note the use of qOverload. It is needed to resolve the ambiguity for the
242 methods, that have multiple overloads.
243
244 Also note that when using QtConcurrent::mappedReduced(), you can mix the use of
245 normal and member functions freely:
246
247 \snippet code/src_concurrent_qtconcurrentmap.cpp 9
248
249 \section2 Using Function Objects
250
251 QtConcurrent::map(), QtConcurrent::mapped(), and
252 QtConcurrent::mappedReduced() accept function objects
253 for the map function. These function objects can be used to
254 add state to a function call:
255
256 \snippet code/src_concurrent_qtconcurrentmap.cpp 14
257
258 Function objects are also supported for the reduce function:
259
260 \snippet code/src_concurrent_qtconcurrentmap.cpp 11
261
262 \section2 Using Lambda Expressions
263
264 QtConcurrent::map(), QtConcurrent::mapped(), and
265 QtConcurrent::mappedReduced() accept lambda expressions for the map and
266 reduce function:
267
268 \snippet code/src_concurrent_qtconcurrentmap.cpp 15
269
270 When using QtConcurrent::mappedReduced() or
271 QtConcurrent::blockingMappedReduced(), you can mix the use of normal
272 functions, member functions and lambda expressions freely.
273
274 \snippet code/src_concurrent_qtconcurrentmap.cpp 16
275
276 You can also pass a lambda as a reduce object:
277
278 \snippet code/src_concurrent_qtconcurrentmap.cpp 17
279
280 \section2 Wrapping Functions that Take Multiple Arguments
281
282 If you want to use a map function that takes more than one argument you can
283 use a lambda function or \c std::bind() to transform it onto a function that
284 takes one argument.
285
286 As an example, we'll use QImage::scaledToWidth():
287
288 \snippet code/src_concurrent_qtconcurrentmap.cpp 10
289
290 scaledToWidth takes three arguments (including the "this" pointer) and
291 can't be used with QtConcurrent::mapped() directly, because
292 QtConcurrent::mapped() expects a function that takes one argument. To use
293 QImage::scaledToWidth() with QtConcurrent::mapped() we have to provide a
294 value for the \e{width} and the \e{transformation mode}:
295
296 \snippet code/src_concurrent_qtconcurrentmap.cpp 13
297*/
298
299/*!
300 \fn template <typename Sequence, typename MapFunctor> QFuture<void> QtConcurrent::map(QThreadPool *pool, Sequence &&sequence, MapFunctor &&function)
301
302 Calls \a function once for each item in \a sequence.
303 All calls to \a function are invoked from the threads taken from the QThreadPool \a pool.
304 The \a function takes a reference to the item, so that any modifications done to the item
305 will appear in \a sequence.
306
307 \sa {Concurrent Map and Map-Reduce}
308*/
309
310/*!
311 \fn template <typename Sequence, typename MapFunctor> QFuture<void> QtConcurrent::map(Sequence &&sequence, MapFunctor &&function)
312
313 Calls \a function once for each item in \a sequence. The \a function takes
314 a reference to the item, so that any modifications done to the item
315 will appear in \a sequence.
316
317 \sa {Concurrent Map and Map-Reduce}
318*/
319
320/*!
321 \fn template <typename Iterator, typename MapFunctor> QFuture<void> QtConcurrent::map(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function)
322
323 Calls \a function once for each item from \a begin to \a end.
324 All calls to \a function are invoked from the threads taken from the QThreadPool \a pool.
325 The \a function takes a reference to the item, so that any modifications
326 done to the item will appear in the sequence which the iterators belong to.
327
328 \sa {Concurrent Map and Map-Reduce}
329*/
330
331/*!
332 \fn template <typename Iterator, typename MapFunctor> QFuture<void> QtConcurrent::map(Iterator begin, Iterator end, MapFunctor &&function)
333
334 Calls \a function once for each item from \a begin to \a end. The
335 \a function takes a reference to the item, so that any modifications
336 done to the item will appear in the sequence which the iterators belong to.
337
338 \sa {Concurrent Map and Map-Reduce}
339*/
340
341/*!
342 \fn template <typename Sequence, typename MapFunctor> QFuture<QtPrivate::MapResultType<Sequence, MapFunctor>> QtConcurrent::mapped(QThreadPool *pool, Sequence &&sequence, MapFunctor &&function)
343
344 Calls \a function once for each item in \a sequence and returns a future
345 with each mapped item as a result. All calls to \a function are invoked from the
346 threads taken from the QThreadPool \a pool. You can use QFuture::const_iterator or
347 QFutureIterator to iterate through the results.
348
349 \sa {Concurrent Map and Map-Reduce}
350*/
351
352/*!
353 \fn template <typename Sequence, typename MapFunctor> QFuture<QtPrivate::MapResultType<Sequence, MapFunctor>> QtConcurrent::mapped(Sequence &&sequence, MapFunctor &&function)
354
355 Calls \a function once for each item in \a sequence and returns a future
356 with each mapped item as a result. You can use QFuture::const_iterator or
357 QFutureIterator to iterate through the results.
358
359 \sa {Concurrent Map and Map-Reduce}
360*/
361
362/*!
363 \fn template <typename Iterator, typename MapFunctor> QFuture<QtPrivate::MapResultType<Iterator, MapFunctor>> QtConcurrent::mapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function)
364
365 Calls \a function once for each item from \a begin to \a end and returns a
366 future with each mapped item as a result. All calls to \a function are invoked from the
367 threads taken from the QThreadPool \a pool. You can use
368 QFuture::const_iterator or QFutureIterator to iterate through the results.
369
370 \sa {Concurrent Map and Map-Reduce}
371*/
372
373/*!
374 \fn template <typename Iterator, typename MapFunctor> QFuture<QtPrivate::MapResultType<Iterator, MapFunctor>> QtConcurrent::mapped(Iterator begin, Iterator end, MapFunctor &&function)
375
376 Calls \a function once for each item from \a begin to \a end and returns a
377 future with each mapped item as a result. You can use
378 QFuture::const_iterator or QFutureIterator to iterate through the results.
379
380 \sa {Concurrent Map and Map-Reduce}
381*/
382
383/*!
384 \fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
385
386 Calls \a mapFunction once for each item in \a sequence.
387 All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
388 The return value of each \a mapFunction is passed to \a reduceFunction.
389
390 Note that while \a mapFunction is called concurrently, only one thread at a
391 time will call \a reduceFunction. The order in which \a reduceFunction is
392 called is determined by \a reduceOptions.
393
394 \sa {Concurrent Map and Map-Reduce}
395*/
396
397/*!
398 \fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
399
400 Calls \a mapFunction once for each item in \a sequence. The return value of
401 each \a mapFunction is passed to \a reduceFunction.
402
403 Note that while \a mapFunction is called concurrently, only one thread at a
404 time will call \a reduceFunction. The order in which \a reduceFunction is
405 called is determined by \a reduceOptions.
406
407 \sa {Concurrent Map and Map-Reduce}
408*/
409
410/*!
411 \fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::mappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
412
413 Calls \a mapFunction once for each item in \a sequence.
414 All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
415 The return value of each \a mapFunction is passed to \a reduceFunction.
416 The result value is initialized to \a initialValue when the function is
417 called, and the first call to \a reduceFunction will operate on
418 this value.
419
420 Note that while \a mapFunction is called concurrently, only one thread at a
421 time will call \a reduceFunction. The order in which \a reduceFunction is
422 called is determined by \a reduceOptions.
423
424 \sa {Concurrent Map and Map-Reduce}
425*/
426
427/*!
428 \fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::mappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
429
430 Calls \a mapFunction once for each item in \a sequence. The return value of
431 each \a mapFunction is passed to \a reduceFunction.
432 The result value is initialized to \a initialValue when the function is
433 called, and the first call to \a reduceFunction will operate on
434 this value.
435
436 Note that while \a mapFunction is called concurrently, only one thread at a
437 time will call \a reduceFunction. The order in which \a reduceFunction is
438 called is determined by \a reduceOptions.
439
440 \sa {Concurrent Map and Map-Reduce}
441*/
442
443/*!
444 \fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
445
446 Calls \a mapFunction once for each item from \a begin to \a end.
447 All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
448 The return value of each \a mapFunction is passed to \a reduceFunction.
449
450 Note that while \a mapFunction is called concurrently, only one thread at a
451 time will call \a reduceFunction. By default, the order in which
452 \a reduceFunction is called is undefined.
453
454 \note QtConcurrent::OrderedReduce results in the ordered reduction.
455
456 \sa {Concurrent Map and Map-Reduce}
457*/
458
459/*!
460 \fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
461
462 Calls \a mapFunction once for each item from \a begin to \a end. The return
463 value of each \a mapFunction is passed to \a reduceFunction.
464
465 Note that while \a mapFunction is called concurrently, only one thread at a
466 time will call \a reduceFunction. By default, the order in which
467 \a reduceFunction is called is undefined.
468
469 \note QtConcurrent::OrderedReduce results in the ordered reduction.
470
471 \sa {Concurrent Map and Map-Reduce}
472*/
473
474/*!
475 \fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::mappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
476
477 Calls \a mapFunction once for each item from \a begin to \a end.
478 All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
479 The return value of each \a mapFunction is passed to \a reduceFunction.
480 The result value is initialized to \a initialValue when the function is
481 called, and the first call to \a reduceFunction will operate on
482 this value.
483
484 Note that while \a mapFunction is called concurrently, only one thread at a
485 time will call \a reduceFunction. By default, the order in which
486 \a reduceFunction is called is undefined.
487
488 \note QtConcurrent::OrderedReduce results in the ordered reduction.
489
490 \sa {Concurrent Map and Map-Reduce}
491*/
492
493/*!
494 \fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::mappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
495
496 Calls \a mapFunction once for each item from \a begin to \a end. The return
497 value of each \a mapFunction is passed to \a reduceFunction.
498 The result value is initialized to \a initialValue when the function is
499 called, and the first call to \a reduceFunction will operate on
500 this value.
501
502 Note that while \a mapFunction is called concurrently, only one thread at a
503 time will call \a reduceFunction. By default, the order in which
504 \a reduceFunction is called is undefined.
505
506 \note QtConcurrent::OrderedReduce results in the ordered reduction.
507
508 \sa {Concurrent Map and Map-Reduce}
509*/
510
511/*!
512 \fn template <typename Sequence, typename MapFunctor> void QtConcurrent::blockingMap(QThreadPool *pool, Sequence &&sequence, MapFunctor function)
513
514 Calls \a function once for each item in \a sequence.
515 All calls to \a function are invoked from the threads taken from the QThreadPool \a pool.
516 The \a function takes a reference to the item, so that any modifications done to the item
517 will appear in \a sequence.
518
519 \note This function will block until all items in the sequence have been processed.
520
521 \sa map(), {Concurrent Map and Map-Reduce}
522*/
523
524/*!
525 \fn template <typename Sequence, typename MapFunctor> void QtConcurrent::blockingMap(Sequence &&sequence, MapFunctor &&function)
526
527 Calls \a function once for each item in \a sequence. The \a function takes
528 a reference to the item, so that any modifications done to the item
529 will appear in \a sequence.
530
531 \note This function will block until all items in the sequence have been processed.
532
533 \sa map(), {Concurrent Map and Map-Reduce}
534*/
535
536/*!
537 \fn template <typename Iterator, typename MapFunctor> void QtConcurrent::blockingMap(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function)
538
539 Calls \a function once for each item from \a begin to \a end.
540 All calls to \a function are invoked from the threads taken from the QThreadPool \a pool.
541 The \a function takes a reference to the item, so that any modifications
542 done to the item will appear in the sequence which the iterators belong to.
543
544 \note This function will block until the iterator reaches the end of the
545 sequence being processed.
546
547 \sa map(), {Concurrent Map and Map-Reduce}
548*/
549
550/*!
551 \fn template <typename Iterator, typename MapFunctor> void QtConcurrent::blockingMap(Iterator begin, Iterator end, MapFunctor &&function)
552
553 Calls \a function once for each item from \a begin to \a end. The
554 \a function takes a reference to the item, so that any modifications
555 done to the item will appear in the sequence which the iterators belong to.
556
557 \note This function will block until the iterator reaches the end of the
558 sequence being processed.
559
560 \sa map(), {Concurrent Map and Map-Reduce}
561*/
562
563/*!
564 \fn template <typename OutputSequence, typename InputSequence, typename MapFunctor> OutputSequence QtConcurrent::blockingMapped(QThreadPool *pool, InputSequence &&sequence, MapFunctor &&function)
565
566 Calls \a function once for each item in \a sequence and returns an OutputSequence containing
567 the results. All calls to \a function are invoked from the threads taken from the QThreadPool
568 \a pool. The type of the results will match the type returned by the MapFunctor.
569
570 \note This function will block until all items in the sequence have been processed.
571
572 \sa mapped(), {Concurrent Map and Map-Reduce}
573*/
574
575/*!
576 \fn template <typename OutputSequence, typename InputSequence, typename MapFunctor> OutputSequence QtConcurrent::blockingMapped(InputSequence &&sequence, MapFunctor &&function)
577
578 Calls \a function once for each item in \a sequence and returns an OutputSequence containing
579 the results. The type of the results will match the type returned by the MapFunctor.
580
581 \note This function will block until all items in the sequence have been processed.
582
583 \sa mapped(), {Concurrent Map and Map-Reduce}
584*/
585
586/*!
587 \fn template <typename Sequence, typename Iterator, typename MapFunctor> Sequence QtConcurrent::blockingMapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function)
588
589 Calls \a function once for each item from \a begin to \a end and returns a
590 container with the results. All calls to \a function are invoked from the threads
591 taken from the QThreadPool \a pool. You can specify the type of container as the a template
592 argument, like this:
593
594 \code
595 QList<int> ints = QtConcurrent::blockingMapped<QList<int> >(beginIterator, endIterator, fn);
596 \endcode
597
598 \note This function will block until the iterator reaches the end of the
599 sequence being processed.
600
601 \sa mapped(), {Concurrent Map and Map-Reduce}
602*/
603
604/*!
605 \fn template <typename Sequence, typename Iterator, typename MapFunctor> Sequence QtConcurrent::blockingMapped(Iterator begin, Iterator end, MapFunctor &&function)
606
607 Calls \a function once for each item from \a begin to \a end and returns a
608 container with the results. You can specify the type of container as the a template
609 argument, like this:
610
611 \code
612 QList<int> ints = QtConcurrent::blockingMapped<QList<int> >(beginIterator, endIterator, fn);
613 \endcode
614
615 \note This function will block until the iterator reaches the end of the
616 sequence being processed.
617
618 \sa mapped(), {Concurrent Map and Map-Reduce}
619*/
620
621/*!
622 \fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
623
624 Calls \a mapFunction once for each item in \a sequence.
625 All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
626 The return value of each \a mapFunction is passed to \a reduceFunction.
627
628 Note that while \a mapFunction is called concurrently, only one thread at a
629 time will call \a reduceFunction. The order in which \a reduceFunction is
630 called is determined by \a reduceOptions.
631
632 \note This function will block until all items in the sequence have been processed.
633
634 \sa mapped(), {Concurrent Map and Map-Reduce}
635*/
636
637/*!
638 \fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
639
640 Calls \a mapFunction once for each item in \a sequence. The return value of
641 each \a mapFunction is passed to \a reduceFunction.
642
643 Note that while \a mapFunction is called concurrently, only one thread at a
644 time will call \a reduceFunction. The order in which \a reduceFunction is
645 called is determined by \a reduceOptions.
646
647 \note This function will block until all items in the sequence have been processed.
648
649 \sa mapped(), {Concurrent Map and Map-Reduce}
650*/
651
652/*!
653 \fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
654
655 Calls \a mapFunction once for each item in \a sequence.
656 All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
657 The return value of each \a mapFunction is passed to \a reduceFunction.
658 The result value is initialized to \a initialValue when the function is
659 called, and the first call to \a reduceFunction will operate on
660 this value.
661
662 Note that while \a mapFunction is called concurrently, only one thread at a
663 time will call \a reduceFunction. The order in which \a reduceFunction is
664 called is determined by \a reduceOptions.
665
666 \note This function will block until all items in the sequence have been processed.
667
668 \sa mapped(), {Concurrent Map and Map-Reduce}
669*/
670
671/*!
672 \fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingMappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
673
674 Calls \a mapFunction once for each item in \a sequence. The return value of
675 each \a mapFunction is passed to \a reduceFunction.
676 The result value is initialized to \a initialValue when the function is
677 called, and the first call to \a reduceFunction will operate on
678 this value.
679
680 Note that while \a mapFunction is called concurrently, only one thread at a
681 time will call \a reduceFunction. The order in which \a reduceFunction is
682 called is determined by \a reduceOptions.
683
684 \note This function will block until all items in the sequence have been processed.
685
686 \sa mapped(), {Concurrent Map and Map-Reduce}
687*/
688
689/*!
690 \fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
691
692 Calls \a mapFunction once for each item from \a begin to \a end.
693 All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
694 The return value of each \a mapFunction is passed to \a reduceFunction.
695
696 Note that while \a mapFunction is called concurrently, only one thread at a
697 time will call \a reduceFunction. The order in which \a reduceFunction is
698 called is undefined.
699
700 \note This function will block until the iterator reaches the end of the
701 sequence being processed.
702
703 \sa blockingMappedReduced(), {Concurrent Map and Map-Reduce}
704*/
705
706/*!
707 \fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
708
709 Calls \a mapFunction once for each item from \a begin to \a end. The return
710 value of each \a mapFunction is passed to \a reduceFunction.
711
712 Note that while \a mapFunction is called concurrently, only one thread at a
713 time will call \a reduceFunction. The order in which \a reduceFunction is
714 called is undefined.
715
716 \note This function will block until the iterator reaches the end of the
717 sequence being processed.
718
719 \sa blockingMappedReduced(), {Concurrent Map and Map-Reduce}
720*/
721
722/*!
723 \fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
724
725 Calls \a mapFunction once for each item from \a begin to \a end.
726 All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
727 The return value of each \a mapFunction is passed to \a reduceFunction.
728 The result value is initialized to \a initialValue when the function is
729 called, and the first call to \a reduceFunction will operate on
730 this value.
731
732 Note that while \a mapFunction is called concurrently, only one thread at a
733 time will call \a reduceFunction. The order in which \a reduceFunction is
734 called is undefined.
735
736 \note This function will block until the iterator reaches the end of the
737 sequence being processed.
738
739 \sa blockingMappedReduced(), {Concurrent Map and Map-Reduce}
740*/
741
742/*!
743 \fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingMappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
744
745 Calls \a mapFunction once for each item from \a begin to \a end. The return
746 value of each \a mapFunction is passed to \a reduceFunction.
747 The result value is initialized to \a initialValue when the function is
748 called, and the first call to \a reduceFunction will operate on
749 this value.
750
751 Note that while \a mapFunction is called concurrently, only one thread at a
752 time will call \a reduceFunction. The order in which \a reduceFunction is
753 called is undefined.
754
755 \note This function will block until the iterator reaches the end of the
756 sequence being processed.
757
758 \sa blockingMappedReduced(), {Concurrent Map and Map-Reduce}
759*/
760

source code of qtbase/src/concurrent/qtconcurrentmap.cpp