diff options
Diffstat (limited to 'src/concurrent')
-rw-r--r-- | src/concurrent/qtconcurrentfilter.cpp | 83 | ||||
-rw-r--r-- | src/concurrent/qtconcurrentfilter.h | 1 | ||||
-rw-r--r-- | src/concurrent/qtconcurrentfilterkernel.h | 4 | ||||
-rw-r--r-- | src/concurrent/qtconcurrentmap.cpp | 94 | ||||
-rw-r--r-- | src/concurrent/qtconcurrentmapkernel.h | 5 | ||||
-rw-r--r-- | src/concurrent/qtconcurrentthreadengine.cpp | 40 | ||||
-rw-r--r-- | src/concurrent/qtconcurrentthreadengine.h | 1 |
7 files changed, 202 insertions, 26 deletions
diff --git a/src/concurrent/qtconcurrentfilter.cpp b/src/concurrent/qtconcurrentfilter.cpp index d4e4656127..c0cbbd3f3d 100644 --- a/src/concurrent/qtconcurrentfilter.cpp +++ b/src/concurrent/qtconcurrentfilter.cpp @@ -175,7 +175,49 @@ */ /*! - \fn QFuture<void> QtConcurrent::filter(Sequence &sequence, FilterFunction filterFunction) + \class QtConcurrent::qValueType + \inmodule QtConcurrent + \internal +*/ + +/*! + \class QtConcurrent::qValueType<const T*> + \inmodule QtConcurrent + \internal +*/ + + +/*! + \class QtConcurrent::qValueType<T*> + \inmodule QtConcurrent + \internal +*/ + +/*! + \class QtConcurrent::FilterKernel + \inmodule QtConcurrent + \internal +*/ + +/*! + \class QtConcurrent::FilteredReducedKernel + \inmodule QtConcurrent + \internal +*/ + +/*! + \class QtConcurrent::FilteredEachKernel + \inmodule QtConcurrent + \internal +*/ + +/*! + \fn [QtConcurrent-1] template <typename Sequence, typename KeepFunctor, typename ReduceFunctor> ThreadEngineStarter<void> QtConcurrent::filterInternal(Sequence &sequence, KeepFunctor keep, ReduceFunctor reduce) + \internal +*/ + +/*! + \fn template <typename Sequence, typename KeepFunctor> QFuture<void> QtConcurrent::filter(Sequence &sequence, KeepFunctor filterFunction) Calls \a filterFunction once for each item in \a sequence. If \a filterFunction returns \c true, the item is kept in \a sequence; @@ -185,7 +227,7 @@ */ /*! - \fn QFuture<T> QtConcurrent::filtered(const Sequence &sequence, FilterFunction filterFunction) + \fn template <typename Sequence, typename KeepFunctor> QFuture<Sequence::value_type> QtConcurrent::filtered(const Sequence &sequence, KeepFunctor filterFunction) Calls \a filterFunction once for each item in \a sequence and returns a new Sequence of kept items. If \a filterFunction returns \c true, a copy of @@ -196,7 +238,7 @@ */ /*! - \fn QFuture<T> QtConcurrent::filtered(ConstIterator begin, ConstIterator end, FilterFunction filterFunction) + \fn template <typename Iterator, typename KeepFunctor> QFuture<typename QtConcurrent::qValueType<Iterator>::value_type> QtConcurrent::filtered(Iterator begin, Iterator end, KeepFunctor filterFunction) Calls \a filterFunction once for each item from \a begin to \a end and returns a new Sequence of kept items. If \a filterFunction returns \c true, a @@ -207,7 +249,7 @@ */ /*! - \fn QFuture<T> QtConcurrent::filteredReduced(const Sequence &sequence, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions) + \fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::filteredReduced(const Sequence &sequence, KeepFunctor filterFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions) Calls \a filterFunction once for each item in \a sequence. If \a filterFunction returns \c true for an item, that item is then passed to @@ -225,7 +267,7 @@ */ /*! - \fn QFuture<T> QtConcurrent::filteredReduced(ConstIterator begin, ConstIterator end, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions) + \fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::filteredReduced(Iterator begin, Iterator end, KeepFunctor filterFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions) Calls \a filterFunction once for each item from \a begin to \a end. If \a filterFunction returns \c true for an item, that item is then passed to @@ -243,7 +285,7 @@ */ /*! - \fn void QtConcurrent::blockingFilter(Sequence &sequence, FilterFunction filterFunction) + \fn template <typename Sequence, typename KeepFunctor> void QtConcurrent::blockingFilter(Sequence &sequence, KeepFunctor filterFunction) Calls \a filterFunction once for each item in \a sequence. If \a filterFunction returns \c true, the item is kept in \a sequence; @@ -255,7 +297,7 @@ */ /*! - \fn Sequence QtConcurrent::blockingFiltered(const Sequence &sequence, FilterFunction filterFunction) + \fn template <typename Sequence, typename KeepFunctor> Sequence QtConcurrent::blockingFiltered(const Sequence &sequence, KeepFunctor filterFunction) Calls \a filterFunction once for each item in \a sequence and returns a new Sequence of kept items. If \a filterFunction returns \c true, a copy of @@ -268,7 +310,7 @@ */ /*! - \fn Sequence QtConcurrent::blockingFiltered(ConstIterator begin, ConstIterator end, FilterFunction filterFunction) + \fn template <typename OutputSequence, typename Iterator, typename KeepFunctor> OutputSequence QtConcurrent::blockingFiltered(Iterator begin, Iterator end, KeepFunctor filterFunction) Calls \a filterFunction once for each item from \a begin to \a end and returns a new Sequence of kept items. If \a filterFunction returns \c true, a @@ -282,7 +324,7 @@ */ /*! - \fn T QtConcurrent::blockingFilteredReduced(const Sequence &sequence, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions) + \fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingFilteredReduced(const Sequence &sequence, KeepFunctor filterFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions) Calls \a filterFunction once for each item in \a sequence. If \a filterFunction returns \c true for an item, that item is then passed to @@ -302,7 +344,7 @@ */ /*! - \fn T QtConcurrent::blockingFilteredReduced(ConstIterator begin, ConstIterator end, FilterFunction filterFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions) + \fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingFilteredReduced(Iterator begin, Iterator end, KeepFunctor filterFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions) Calls \a filterFunction once for each item from \a begin to \a end. If \a filterFunction returns \c true for an item, that item is then passed to @@ -321,3 +363,24 @@ \sa filteredReduced(), {Concurrent Filter and Filter-Reduce} */ + +/*! + \fn [QtConcurrent-2] ThreadEngineStarter<typename qValueType<Iterator>::value_type> QtConcurrent::startFiltered(Iterator begin, Iterator end, KeepFunctor functor) + \internal +*/ + +/*! + \fn [QtConcurrent-3] ThreadEngineStarter<typename Sequence::value_type> QtConcurrent::startFiltered(const Sequence &sequence, KeepFunctor functor) + \internal +*/ + +/*! + \fn [QtConcurrent-4] ThreadEngineStarter<ResultType> QtConcurrent::startFilteredReduced(const Sequence & sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options) + \internal +*/ + +/*! + \fn [QtConcurrent-5] ThreadEngineStarter<ResultType> QtConcurrent::startFilteredReduced(Iterator begin, Iterator end, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options) + \internal +*/ + diff --git a/src/concurrent/qtconcurrentfilter.h b/src/concurrent/qtconcurrentfilter.h index e09f3b4abc..5f4148091e 100644 --- a/src/concurrent/qtconcurrentfilter.h +++ b/src/concurrent/qtconcurrentfilter.h @@ -98,6 +98,7 @@ namespace QtConcurrent { namespace QtConcurrent { +//! [QtConcurrent-1] template <typename Sequence, typename KeepFunctor, typename ReduceFunctor> ThreadEngineStarter<void> filterInternal(Sequence &sequence, KeepFunctor keep, ReduceFunctor reduce) { diff --git a/src/concurrent/qtconcurrentfilterkernel.h b/src/concurrent/qtconcurrentfilterkernel.h index bd474fc0c9..4500bd4f8a 100644 --- a/src/concurrent/qtconcurrentfilterkernel.h +++ b/src/concurrent/qtconcurrentfilterkernel.h @@ -292,6 +292,7 @@ public: } }; +//! [QtConcurrent-2] template <typename Iterator, typename KeepFunctor> inline ThreadEngineStarter<typename qValueType<Iterator>::value_type> @@ -300,6 +301,7 @@ startFiltered(Iterator begin, Iterator end, KeepFunctor functor) return startThreadEngine(new FilteredEachKernel<Iterator, KeepFunctor>(begin, end, functor)); } +//! [QtConcurrent-3] template <typename Sequence, typename KeepFunctor> inline ThreadEngineStarter<typename Sequence::value_type> startFiltered(const Sequence &sequence, KeepFunctor functor) @@ -311,6 +313,7 @@ startFiltered(const Sequence &sequence, KeepFunctor functor) return startThreadEngine(new SequenceHolderType(sequence, functor)); } +//! [QtConcurrent-4] template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> inline ThreadEngineStarter<ResultType> startFilteredReduced(const Sequence & sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, @@ -324,6 +327,7 @@ inline ThreadEngineStarter<ResultType> startFilteredReduced(const Sequence & seq } +//! [QtConcurrent-5] template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> inline ThreadEngineStarter<ResultType> startFilteredReduced(Iterator begin, Iterator end, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, diff --git a/src/concurrent/qtconcurrentmap.cpp b/src/concurrent/qtconcurrentmap.cpp index 1ba5de355b..9c01b65611 100644 --- a/src/concurrent/qtconcurrentmap.cpp +++ b/src/concurrent/qtconcurrentmap.cpp @@ -53,6 +53,72 @@ */ /*! + \enum QtConcurrent::ReduceQueueLimits + \internal + */ + +/*! + \class QtConcurrent::ReduceKernel + \inmodule QtConcurrent + \internal +*/ + +/*! + \class QtConcurrent::SequenceHolder2 + \inmodule QtConcurrent + \internal +*/ + +/*! + \class QtConcurrent::MapKernel + \inmodule QtConcurrent + \internal +*/ + +/*! + \class QtConcurrent::MappedReducedKernel + \inmodule QtConcurrent + \internal +*/ + +/*! + \class QtConcurrent::MappedEachKernel + \inmodule QtConcurrent + \internal +*/ + +/*! + \class QtConcurrent::SequenceHolder1 + \inmodule QtConcurrent + \internal +*/ + +/*! + \fn [qtconcurrentmapkernel-1] ThreadEngineStarter<void> QtConcurrent::startMap(Iterator begin, Iterator end, Functor functor) + \internal +*/ + +/*! + \fn [qtconcurrentmapkernel-2] ThreadEngineStarter<T> QtConcurrent::startMapped(Iterator begin, Iterator end, Functor functor) + \internal +*/ + +/*! + \fn [qtconcurrentmapkernel-3] ThreadEngineStarter<T> QtConcurrent::startMapped(const Sequence &sequence, Functor functor) + \internal +*/ + +/*! + \fn [qtconcurrentmapkernel-4] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(const Sequence & sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options) + \internal +*/ + +/*! + \fn [qtconcurrentmapkernel-5] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Iterator begin, Iterator end, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options) + \internal +*/ + +/*! \enum QtConcurrent::ReduceOption This enum specifies the order of which results from the map or filter function are passed to the reduce function. @@ -225,7 +291,7 @@ */ /*! - \fn QFuture<void> QtConcurrent::map(Sequence &sequence, MapFunction function) + \fn template <typename Sequence, typename MapFunctor> QFuture<void> QtConcurrent::map(Sequence &sequence, MapFunctor function) Calls \a function once for each item in \a sequence. The \a function is passed a reference to the item, so that any modifications done to the item @@ -235,7 +301,7 @@ */ /*! - \fn QFuture<void> QtConcurrent::map(Iterator begin, Iterator end, MapFunction function) + \fn template <typename Iterator, typename MapFunctor> QFuture<void> QtConcurrent::map(Iterator begin, Iterator end, MapFunctor function) Calls \a function once for each item from \a begin to \a end. The \a function is passed a reference to the item, so that any modifications @@ -245,7 +311,7 @@ */ /*! - \fn QFuture<T> QtConcurrent::mapped(const Sequence &sequence, MapFunction function) + \fn template <typename Sequence, typename MapFunctor> QFuture<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType> QtConcurrent::mapped(const Sequence &sequence, MapFunctor function) Calls \a function once for each item in \a sequence and returns a future with each mapped item as a result. You can use QFuture::const_iterator or @@ -255,7 +321,7 @@ */ /*! - \fn QFuture<T> QtConcurrent::mapped(ConstIterator begin, ConstIterator end, MapFunction function) + \fn template <typename Iterator, typename MapFunctor> QFuture<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType> QtConcurrent::mapped(Iterator begin, Iterator end, MapFunctor function) Calls \a function once for each item from \a begin to \a end and returns a future with each mapped item as a result. You can use @@ -265,9 +331,7 @@ */ /*! - \fn QFuture<T> QtConcurrent::mappedReduced(const Sequence &sequence, - MapFunction mapFunction, ReduceFunction reduceFunction, - QtConcurrent::ReduceOptions reduceOptions) + \fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(const Sequence &sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions) Calls \a mapFunction once for each item in \a sequence. The return value of each \a mapFunction is passed to \a reduceFunction. @@ -280,9 +344,7 @@ */ /*! - \fn QFuture<T> QtConcurrent::mappedReduced(ConstIterator begin, - ConstIterator end, MapFunction mapFunction, ReduceFunction reduceFunction, - QtConcurrent::ReduceOptions reduceOptions) + \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) Calls \a mapFunction once for each item from \a begin to \a end. The return value of each \a mapFunction is passed to \a reduceFunction. @@ -297,7 +359,7 @@ */ /*! - \fn void QtConcurrent::blockingMap(Sequence &sequence, MapFunction function) + \fn template <typename Sequence, typename MapFunctor> void QtConcurrent::blockingMap(Sequence &sequence, MapFunctor function) Calls \a function once for each item in \a sequence. The \a function is passed a reference to the item, so that any modifications done to the item @@ -309,7 +371,7 @@ */ /*! - \fn void QtConcurrent::blockingMap(Iterator begin, Iterator end, MapFunction function) + \fn template <typename Iterator, typename MapFunctor> void QtConcurrent::blockingMap(Iterator begin, Iterator end, MapFunctor function) Calls \a function once for each item from \a begin to \a end. The \a function is passed a reference to the item, so that any modifications @@ -322,7 +384,7 @@ */ /*! - \fn T QtConcurrent::blockingMapped(const Sequence &sequence, MapFunction function) + \fn template <typename OutputSequence, typename InputSequence, typename MapFunctor> OutputSequence QtConcurrent::blockingMapped(const InputSequence &sequence, MapFunctor function) Calls \a function once for each item in \a sequence and returns a Sequence containing the results. The type of the results will match the type returned my the MapFunction. @@ -333,7 +395,7 @@ */ /*! - \fn T QtConcurrent::blockingMapped(ConstIterator begin, ConstIterator end, MapFunction function) + \fn template <typename Sequence, typename Iterator, typename MapFunctor> Sequence QtConcurrent::blockingMapped(Iterator begin, Iterator end, MapFunctor function) Calls \a function once for each item from \a begin to \a end and returns a container with the results. Specify the type of container as the a template @@ -350,7 +412,7 @@ */ /*! - \fn T QtConcurrent::blockingMappedReduced(const Sequence &sequence, MapFunction mapFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions) + \fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(const Sequence &sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions) Calls \a mapFunction once for each item in \a sequence. The return value of each \a mapFunction is passed to \a reduceFunction. @@ -365,7 +427,7 @@ */ /*! - \fn T QtConcurrent::blockingMappedReduced(ConstIterator begin, ConstIterator end, MapFunction mapFunction, ReduceFunction reduceFunction, QtConcurrent::ReduceOptions reduceOptions) + \fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(Iterator begin, Iterator end, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions) Calls \a mapFunction once for each item from \a begin to \a end. The return value of each \a mapFunction is passed to \a reduceFunction. diff --git a/src/concurrent/qtconcurrentmapkernel.h b/src/concurrent/qtconcurrentmapkernel.h index fa162f7c34..26e755c819 100644 --- a/src/concurrent/qtconcurrentmapkernel.h +++ b/src/concurrent/qtconcurrentmapkernel.h @@ -191,12 +191,14 @@ public: } }; +//! [qtconcurrentmapkernel-1] template <typename Iterator, typename Functor> inline ThreadEngineStarter<void> startMap(Iterator begin, Iterator end, Functor functor) { return startThreadEngine(new MapKernel<Iterator, Functor>(begin, end, functor)); } +//! [qtconcurrentmapkernel-2] template <typename T, typename Iterator, typename Functor> inline ThreadEngineStarter<T> startMapped(Iterator begin, Iterator end, Functor functor) { @@ -225,6 +227,7 @@ struct SequenceHolder1 : public Base } }; +//! [qtconcurrentmapkernel-3] template <typename T, typename Sequence, typename Functor> inline ThreadEngineStarter<T> startMapped(const Sequence &sequence, Functor functor) { @@ -235,6 +238,7 @@ inline ThreadEngineStarter<T> startMapped(const Sequence &sequence, Functor func return startThreadEngine(new SequenceHolderType(sequence, functor)); } +//! [qtconcurrentmapkernel-4] template <typename IntermediateType, typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> inline ThreadEngineStarter<ResultType> startMappedReduced(const Sequence & sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, @@ -247,6 +251,7 @@ inline ThreadEngineStarter<ResultType> startMappedReduced(const Sequence & seque return startThreadEngine(new SequenceHolderType(sequence, mapFunctor, reduceFunctor, options)); } +//! [qtconcurrentmapkernel-5] template <typename IntermediateType, typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> inline ThreadEngineStarter<ResultType> startMappedReduced(Iterator begin, Iterator end, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, diff --git a/src/concurrent/qtconcurrentthreadengine.cpp b/src/concurrent/qtconcurrentthreadengine.cpp index c7791f8571..2e27e0e83c 100644 --- a/src/concurrent/qtconcurrentthreadengine.cpp +++ b/src/concurrent/qtconcurrentthreadengine.cpp @@ -45,6 +45,46 @@ QT_BEGIN_NAMESPACE namespace QtConcurrent { +/*! + \class QtConcurrent::ThreadEngineBarrier + \inmodule QtConcurrent + \internal +*/ + +/*! + \enum QtConcurrent::ThreadFunctionResult + \internal +*/ + +/*! + \class QtConcurrent::ThreadEngineBase + \inmodule QtConcurrent + \internal +*/ + +/*! + \class QtConcurrent::ThreadEngine + \inmodule QtConcurrent + \internal +*/ + +/*! + \class QtConcurrent::ThreadEngineStarterBase + \inmodule QtConcurrent + \internal +*/ + +/*! + \class QtConcurrent::ThreadEngineStarter + \inmodule QtConcurrent + \internal +*/ + +/*! + \fn [qtconcurrentthreadengine-1] template <typename ThreadEngine> ThreadEngineStarter<typename ThreadEngine::ResultType> QtConcurrent::startThreadEngine(ThreadEngine *threadEngine) + \internal +*/ + ThreadEngineBarrier::ThreadEngineBarrier() :count(0) { } diff --git a/src/concurrent/qtconcurrentthreadengine.h b/src/concurrent/qtconcurrentthreadengine.h index 450e7b8d50..0941f559f2 100644 --- a/src/concurrent/qtconcurrentthreadengine.h +++ b/src/concurrent/qtconcurrentthreadengine.h @@ -259,6 +259,7 @@ public: } }; +//! [qtconcurrentthreadengine-1] template <typename ThreadEngine> inline ThreadEngineStarter<typename ThreadEngine::ResultType> startThreadEngine(ThreadEngine *threadEngine) { |