- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions

# ReduceKernel< ReduceFunctor, ReduceResultType, T > Class Template Reference

Search for all occurrences

## Detailed Description

### template<typename ReduceFunctor, typename ReduceResultType, typename T>
class QtConcurrent::ReduceKernel< ReduceFunctor, ReduceResultType, T >

Definition at line 104 of file qtconcurrentreducekernel.h.

`#include <qtconcurrentreducekernel.h>`

List of all members.

## Public Member Functions
| ReduceKernel (ReduceOptions _reduceOptions)
void | runReduce (ReduceFunctor &reduce, ReduceResultType &r, const IntermediateResults< T > &result)
void | finish (ReduceFunctor &reduce, ReduceResultType &r)
bool | shouldThrottle ()
bool | shouldStartThread ()

## Constructor & Destructor Documentation

ReduceKernel | ( | ReduceOptions | _reduceOptions | ) | `[inline]`

Definition at line 143 of file qtconcurrentreducekernel.h.

            : reduceOptions(_reduceOptions), progress(0), resultsMapSize(0),
              threadCount(QThreadPool::globalInstance()->maxThreadCount())
        { }

## Member Function Documentation

void runReduce | ( | ReduceFunctor & | reduce,
|  | ReduceResultType & | r,
|  | const IntermediateResults< T > & | result
| ) |  | `[inline]`

Search for all occurrences

Definition at line 148 of file qtconcurrentreducekernel.h.

        {
            QMutexLocker locker(&mutex);
            if (!canReduce(result.begin)) {
                ++resultsMapSize;
                resultsMap.insert(result.begin, result);
                return;
            }

            if (reduceOptions & UnorderedReduce) {
                // UnorderedReduce
                progress = -1;

                // reduce this result
                locker.unlock();
                reduceResult(reduce, r, result);
                locker.relock();

                // reduce all stored results as well
                while (!resultsMap.isEmpty()) {
                    ResultsMap resultsMapCopy = resultsMap;
                    resultsMap.clear();

                    locker.unlock();
                    reduceResults(reduce, r, resultsMapCopy);
                    locker.relock();

                    resultsMapSize -= resultsMapCopy.size();
                }

                progress = 0;
            } else {
                // reduce this result
                locker.unlock();
                reduceResult(reduce, r, result);
                locker.relock();

                // OrderedReduce
                progress += result.end - result.begin;

                // reduce as many other results as possible
                typename ResultsMap::iterator it = resultsMap.begin();
                while (it != resultsMap.end()) {
                    if (it.value().begin != progress)
                        break;

                    locker.unlock();
                    reduceResult(reduce, r, it.value());
                    locker.relock();

                    --resultsMapSize;
                    progress += it.value().end - it.value().begin;
                    it = resultsMap.erase(it);
                }
            }
        }

void finish | ( | ReduceFunctor & | reduce,
|  | ReduceResultType & | r
| ) |  | `[inline]`

Search for all occurrences

Definition at line 208 of file qtconcurrentreducekernel.h.

        {
            reduceResults(reduce, r, resultsMap);
        }

bool shouldThrottle | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 213 of file qtconcurrentreducekernel.h.

        {
            return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount));
        }

bool shouldStartThread | ( |  | ) | `[inline]`

Search for all occurrences

Definition at line 218 of file qtconcurrentreducekernel.h.

        {
            return (resultsMapSize <= (ReduceQueueStartLimit * threadCount));
        }

The documentation for this class was generated from the following file:

- QtCore/qtconcurrentreducekernel.h