Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtconcurrentiteratekernel.cpp
Go to the documentation of this file.
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
6
7#include <qdeadlinetimer.h>
8#include "private/qfunctions_p.h"
9
10
11#if !defined(QT_NO_CONCURRENT) || defined(Q_QDOC)
12
13QT_BEGIN_NAMESPACE
14
15enum {
16 TargetRatio = 100
17};
18
20{
21 return QDeadlineTimer::current(Qt::PreciseTimer).deadlineNSecs();
22}
23
24static double elapsed(qint64 after, qint64 before)
25{
26 return double(after - before);
27}
28
29namespace QtConcurrent {
30
31/*!
32 \class QtConcurrent::Median
33 \inmodule QtConcurrent
34 \internal
35 */
36
37/*!
38 \class QtConcurrent::BlockSizeManager
39 \inmodule QtConcurrent
40 \internal
41 */
42
43/*!
44 \class QtConcurrent::ResultReporter
45 \inmodule QtConcurrent
46 \internal
47 */
48
49/*! \fn bool QtConcurrent::selectIteration(std::bidirectional_iterator_tag)
50 \internal
51 */
52
53/*! \fn bool QtConcurrent::selectIteration(std::forward_iterator_tag)
54 \internal
55 */
56
57/*! \fn bool QtConcurrent::selectIteration(std::random_access_iterator_tag)
58 \internal
59 */
60
61/*!
62 \class QtConcurrent::IterateKernel
63 \inmodule QtConcurrent
64 \internal
65 */
66
67/*! \internal
68
69*/
75
76// Records the time before user code.
85
86 // Records the time after user code and adjust the block size if we are spending
87 // to much time in the for control code compared with the user code.
89{
90 if (blockSizeMaxed())
91 return;
92
95
96 if (controlPartElapsed.isMedianValid() == false)
97 return;
98
100 return;
101
103
104#ifdef QTCONCURRENT_FOR_DEBUG
105 qDebug() << QThread::currentThread() << "adjusting block size" << controlPartElapsed.median() << userPartElapsed.median() << m_blockSize;
106#endif
107
108 // Reset the medians after adjusting the block size so we get
109 // new measurements with the new block size.
112}
113
115{
116 return m_blockSize;
117}
118
119} // namespace QtConcurrent
120
121QT_END_NAMESPACE
122
123#endif // QT_NO_CONCURRENT
\inmodule QtConcurrent
static qint64 getticks()
static double elapsed(qint64 after, qint64 before)