diff options
Diffstat (limited to 'src/concurrent/qtconcurrentreducekernel.h')
-rw-r--r-- | src/concurrent/qtconcurrentreducekernel.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/concurrent/qtconcurrentreducekernel.h b/src/concurrent/qtconcurrentreducekernel.h index 9ea0f33f91..c337a9192f 100644 --- a/src/concurrent/qtconcurrentreducekernel.h +++ b/src/concurrent/qtconcurrentreducekernel.h @@ -5,9 +5,8 @@ #define QTCONCURRENT_REDUCEKERNEL_H #include <QtConcurrent/qtconcurrent_global.h> -#include <QtConcurrent/qtconcurrentfunctionwrappers.h> -#if !defined(QT_NO_CONCURRENT) || defined(Q_CLANG_QDOC) +#if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC) #include <QtCore/qatomic.h> #include <QtCore/qlist.h> @@ -20,6 +19,17 @@ QT_BEGIN_NAMESPACE +namespace QtPrivate { + +template<typename Sequence> +struct SequenceHolder +{ + SequenceHolder(const Sequence &s) : sequence(s) { } + SequenceHolder(Sequence &&s) : sequence(std::move(s)) { } + Sequence sequence; +}; + +} namespace QtConcurrent { @@ -30,7 +40,7 @@ namespace QtConcurrent { MapReduce won't start any new threads, and when it exceeds ReduceQueueThrottleLimit running threads will be stopped. */ -#ifdef Q_CLANG_QDOC +#ifdef Q_QDOC enum ReduceQueueLimits { ReduceQueueStartLimit = 20, ReduceQueueThrottleLimit = 30 @@ -60,7 +70,7 @@ enum ReduceOption { // ParallelReduce = 0x8 }; Q_DECLARE_FLAGS(ReduceOptions, ReduceOption) -#ifndef Q_CLANG_QDOC +#ifndef Q_QDOC Q_DECLARE_OPERATORS_FOR_FLAGS(ReduceOptions) #endif // supports both ordered and out-of-order reduction @@ -107,7 +117,7 @@ class ReduceKernel public: ReduceKernel(QThreadPool *pool, ReduceOptions _reduceOptions) : reduceOptions(_reduceOptions), progress(0), resultsMapSize(0), - threadCount(pool->maxThreadCount()) + threadCount(std::max(pool->maxThreadCount(), 1)) { } void runReduce(ReduceFunctor &reduce, @@ -177,11 +187,13 @@ public: inline bool shouldThrottle() { + std::lock_guard<QMutex> locker(mutex); return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount)); } inline bool shouldStartThread() { + std::lock_guard<QMutex> locker(mutex); return (resultsMapSize <= (ReduceQueueStartLimit * threadCount)); } }; |