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