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
qqmlabstractprofileradapter.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
7
8/*!
9 * \internal
10 * \class QQmlAbstractProfilerAdapter
11 * \inmodule QtQml
12 * Abstract base class for all adapters between profilers and the QQmlProfilerService. Adapters have
13 * to retrieve profiler-specific data and convert it to the format sent over the wire. Adapters must
14 * live in the QDebugServer thread but the actual profilers can live in different threads. The
15 * recommended way to deal with this is passing the profiling data through a signal/slot connection.
16 */
17
18/*!
19 * \internal
20 * \fn void QQmlAbstractProfilerAdapter::dataRequested()
21 * Signals that data has been requested by the \c QQmlProfilerService. This signal should be
22 * connected to a slot in the profiler and the profiler should then transfer its currently available
23 * profiling data to the adapter as soon as possible.
24 */
25
26/*!
27 * \internal
28 * \fn qint64 QQmlAbstractProfilerAdapter::sendMessages(qint64 until, QList<QByteArray> &messages)
29 * Append the messages up to the timestamp \a until, chronologically sorted, to \a messages. Keep
30 * track of the messages already sent and with each subsequent call to this method start with the
31 * first one not yet sent. Messages that have been sent can be deleted. When new data from the
32 * profiler arrives the information about the last sent message must be reset. Return the timestamp
33 * of the next message after \a until or \c -1 if there is no such message.
34 * The profiler service keeps a list of adapters, sorted by time of next message and keeps querying
35 * the first one to send messages up to the time of the second one. Like that we get chronologically
36 * sorted messages and can occasionally post the messages to exploit parallelism and save memory.
37 */
38
39/*!
40 * \internal
41 * Emits either \c profilingEnabled(quint64) or \c profilingEnabledWhileWaiting(quint64), depending
42 * on \c waiting. If the profiler's thread is waiting for an initial start signal, we can emit the
43 * signal over a Qt::DirectConnection to avoid the delay of the event loop. The \a features are
44 * passed on to the signal.
45 */
46void QQmlAbstractProfilerAdapter::startProfiling(quint64 features)
47{
48 if (waiting)
49 emit profilingEnabledWhileWaiting(features);
50 else
51 emit profilingEnabled(features);
52 featuresEnabled = features;
53 running = true;
54}
55
56/*!
57 * \internal
58 * Emits either \c profilingDisabled() or \c profilingDisabledWhileWaiting(), depending on
59 * \c waiting. If the profiler's thread is waiting for an initial start signal, we can emit the
60 * signal over a Qt::DirectConnection to avoid the delay of the event loop. This should trigger
61 * the profiler to report its collected data and subsequently delete it.
62 */
63void QQmlAbstractProfilerAdapter::stopProfiling() {
64 if (waiting)
65 emit profilingDisabledWhileWaiting();
66 else
67 emit profilingDisabled();
68 featuresEnabled = 0;
69 running = false;
70}
71
72/*!
73 * \internal
74 * \fn bool QQmlAbstractProfilerAdapter::isRunning() const
75 * Returns if the profiler is currently running. The profiler is considered to be running after
76 * \c startProfiling(quint64) has been called until \c stopProfiling() is called. That is
77 * independent of \c waiting. The profiler may be running and waiting at the same time.
78 */
79
80/*!
81 * \internal
82 * \fn void QQmlAbstractProfilerAdapter::profilingDisabled()
83 * This signal is emitted if \c stopProfiling() is called while the profiler is not considered to
84 * be waiting. The profiler is expected to handle the signal asynchronously.
85 */
86
87/*!
88 * \internal
89 * \fn void QQmlAbstractProfilerAdapter::profilingDisabledWhileWaiting()
90 * This signal is emitted if \c stopProfiling() is called while the profiler is considered to be
91 * waiting. In many cases this signal can be connected with a Qt::DirectConnection.
92 */
93
94/*!
95 * \internal
96 * \fn void QQmlAbstractProfilerAdapter::profilingEnabled(quint64 features)
97 * This signal is emitted if \c startProfiling(quint64) is called while the profiler is not
98 * considered to be waiting. The profiler is expected to handle the signal asynchronously. The
99 * \a features are passed on from \c startProfiling(quint64).
100 */
101
102/*!
103 * \internal
104 * \fn void QQmlAbstractProfilerAdapter::profilingEnabledWhileWaiting(quint64 features)
105 * This signal is emitted if \c startProfiling(quint64) is called while the profiler is considered
106 * to be waiting. In many cases this signal can be connected with a Qt::DirectConnection. By
107 * starting the profiler synchronously when the QML engine starts instead of waiting for the first
108 * iteration of the event loop the engine startup can be profiled. The \a features are passed on
109 * from \c startProfiling(quint64).
110 */
111
112/*!
113 * \internal
114 * \fn void QQmlAbstractProfilerAdapter::referenceTimeKnown(const QElapsedTimer &timer)
115 * This signal is used to synchronize the profiler's timer to the QQmlProfilerservice's. The
116 * profiler is expected to save \a timer and use it for timestamps on its data.
117 */
118
119/*!
120 * \internal
121 * \fn void QQmlAbstractProfilerAdapter::synchronize(const QElapsedTimer &timer)
122 * Synchronize the profiler to \a timer. This emits \c referenceTimeKnown().
123 */
124
125/*!
126 * \internal
127 * \fn void QQmlAbstractProfilerAdapter::reportData()
128 * Make the profiler report its current data without stopping the collection. The same (and
129 * additional) data can later be requested again with \c stopProfiling() or \c reportData().
130 */
131
132/*!
133 * \internal
134 * \fn void QQmlAbstractProfilerAdapter::startWaiting()
135 * Consider the profiler to be waiting from now on. While the profiler is waiting it can be directly
136 * accessed even if it is in a different thread. This method should only be called if it is actually
137 * safe to do so.
138 */
139
140/*!
141 * \internal
142 * \fn void QQmlAbstractProfilerAdapter::stopWaiting()
143 * Consider the profiler not to be waiting anymore. If it lives in a different threads any requests
144 * for it have to be done via a queued connection then.
145 */
146
147QT_END_NAMESPACE
148
149#include "moc_qqmlabstractprofileradapter_p.cpp"
Combined button and popup list for selecting options.