thread/qfuturewatcher.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qfuturewatcher.h" -
43 -
44#ifndef QT_NO_QFUTURE -
45 -
46#include "qfuturewatcher_p.h" -
47 -
48#include <QtCore/qcoreevent.h> -
49#include <QtCore/qcoreapplication.h> -
50#include <QtCore/qmetaobject.h> -
51#include <QtCore/qthread.h> -
52 -
53QT_BEGIN_NAMESPACE -
54 -
55/*! \class QFutureWatcher -
56 \reentrant -
57 \since 4.4 -
58 -
59 \inmodule QtCore -
60 \ingroup thread -
61 -
62 \brief The QFutureWatcher class allows monitoring a QFuture using signals -
63 and slots. -
64 -
65 QFutureWatcher provides information and notifications about a QFuture. Use -
66 the setFuture() function to start watching a particular QFuture. The -
67 future() function returns the future set with setFuture(). -
68 -
69 For convenience, several of QFuture's functions are also available in -
70 QFutureWatcher: progressValue(), progressMinimum(), progressMaximum(), -
71 progressText(), isStarted(), isFinished(), isRunning(), isCanceled(), -
72 isPaused(), waitForFinished(), result(), and resultAt(). The cancel(), -
73 setPaused(), pause(), resume(), and togglePaused() functions are slots in -
74 QFutureWatcher. -
75 -
76 Status changes are reported via the started(), finished(), canceled(), -
77 paused(), resumed(), resultReadyAt(), and resultsReadyAt() signals. -
78 Progress information is provided from the progressRangeChanged(), -
79 void progressValueChanged(), and progressTextChanged() signals. -
80 -
81 Throttling control is provided by the setPendingResultsLimit() function. -
82 When the number of pending resultReadyAt() or resultsReadyAt() signals -
83 exceeds the limit, the computation represented by the future will be -
84 throttled automatically. The computation will resume once the number of -
85 pending signals drops below the limit. -
86 -
87 Example: Starting a computation and getting a slot callback when it's -
88 finished: -
89 -
90 \snippet code/src_corelib_thread_qfuturewatcher.cpp 0 -
91 -
92 Be aware that not all asynchronous computations can be canceled or paused. -
93 For example, the future returned by QtConcurrent::run() cannot be -
94 canceled; but the future returned by QtConcurrent::mappedReduced() can. -
95 -
96 QFutureWatcher<void> is specialized to not contain any of the result -
97 fetching functions. Any QFuture<T> can be watched by a -
98 QFutureWatcher<void> as well. This is useful if only status or progress -
99 information is needed; not the actual result data. -
100 -
101 \sa QFuture, {Concurrent Programming}{Qt Concurrent} -
102*/ -
103 -
104/*! \fn QFutureWatcher::QFutureWatcher(QObject *parent) -
105 -
106 Constructs a new QFutureWatcher with the given \a parent. -
107*/ -
108QFutureWatcherBase::QFutureWatcherBase(QObject *parent) -
109 :QObject(*new QFutureWatcherBasePrivate, parent) -
110{ }
executed: }
Execution Count:22
22
111 -
112/*! \fn QFutureWatcher::~QFutureWatcher() -
113 -
114 Destroys the QFutureWatcher. -
115*/ -
116 -
117/*! \fn void QFutureWatcher::cancel() -
118 -
119 Cancels the asynchronous computation represented by the future(). Note that -
120 the cancelation is asynchronous. Use waitForFinished() after calling -
121 cancel() when you need synchronous cancelation. -
122 -
123 Currently available results may still be accessed on a canceled QFuture, -
124 but new results will \e not become available after calling this function. -
125 Also, this QFutureWatcher will not deliver progress and result ready -
126 signals once canceled. This includes the progressValueChanged(), -
127 progressRangeChanged(), progressTextChanged(), resultReadyAt(), and -
128 resultsReadyAt() signals. -
129 -
130 Be aware that not all asynchronous computations can be canceled. For -
131 example, the QFuture returned by QtConcurrent::run() cannot be canceled; -
132 but the QFuture returned by QtConcurrent::mappedReduced() can. -
133*/ -
134void QFutureWatcherBase::cancel() -
135{ -
136 futureInterface().cancel();
executed (the execution status of this line is deduced): futureInterface().cancel();
-
137}
executed: }
Execution Count:5
5
138 -
139/*! \fn void QFutureWatcher::setPaused(bool paused) -
140 -
141 If \a paused is true, this function pauses the asynchronous computation -
142 represented by the future(). If the computation is already paused, this -
143 function does nothing. This QFutureWatcher will stop delivering progress -
144 and result ready signals while the future is paused. Signal delivery will -
145 continue once the computation is resumed. -
146 -
147 If \a paused is false, this function resumes the asynchronous computation. -
148 If the computation was not previously paused, this function does nothing. -
149 -
150 Be aware that not all computations can be paused. For example, the -
151 QFuture returned by QtConcurrent::run() cannot be paused; but the QFuture -
152 returned by QtConcurrent::mappedReduced() can. -
153 -
154 \sa pause(), resume(), togglePaused() -
155*/ -
156void QFutureWatcherBase::setPaused(bool paused) -
157{ -
158 futureInterface().setPaused(paused);
never executed (the execution status of this line is deduced): futureInterface().setPaused(paused);
-
159}
never executed: }
0
160 -
161/*! \fn void QFutureWatcher::pause() -
162 -
163 Pauses the asynchronous computation represented by the future(). This is a -
164 convenience method that simply calls setPaused(true). -
165 -
166 \sa resume() -
167*/ -
168void QFutureWatcherBase::pause() -
169{ -
170 futureInterface().setPaused(true);
executed (the execution status of this line is deduced): futureInterface().setPaused(true);
-
171}
executed: }
Execution Count:4
4
172 -
173/*! \fn void QFutureWatcher::resume() -
174 -
175 Resumes the asynchronous computation represented by the future(). This is -
176 a convenience method that simply calls setPaused(false). -
177 -
178 \sa pause() -
179*/ -
180void QFutureWatcherBase::resume() -
181{ -
182 futureInterface().setPaused(false);
executed (the execution status of this line is deduced): futureInterface().setPaused(false);
-
183}
executed: }
Execution Count:4
4
184 -
185/*! \fn void QFutureWatcher::togglePaused() -
186 -
187 Toggles the paused state of the asynchronous computation. In other words, -
188 if the computation is currently paused, calling this function resumes it; -
189 if the computation is running, it becomes paused. This is a convenience -
190 method for calling setPaused(!isPaused()). -
191 -
192 \sa setPaused(), pause(), resume() -
193*/ -
194void QFutureWatcherBase::togglePaused() -
195{ -
196 futureInterface().togglePaused();
executed (the execution status of this line is deduced): futureInterface().togglePaused();
-
197}
executed: }
Execution Count:3
3
198 -
199/*! \fn int QFutureWatcher::progressValue() const -
200 -
201 Returns the current progress value, which is between the progressMinimum() -
202 and progressMaximum(). -
203 -
204 \sa progressMinimum(), progressMaximum() -
205*/ -
206int QFutureWatcherBase::progressValue() const -
207{ -
208 return futureInterface().progressValue();
executed: return futureInterface().progressValue();
Execution Count:6
6
209} -
210 -
211/*! \fn int QFutureWatcher::progressMinimum() const -
212 -
213 Returns the minimum progressValue(). -
214 -
215 \sa progressValue(), progressMaximum() -
216*/ -
217int QFutureWatcherBase::progressMinimum() const -
218{ -
219 return futureInterface().progressMinimum();
executed: return futureInterface().progressMinimum();
Execution Count:6
6
220} -
221 -
222/*! \fn int QFutureWatcher::progressMaximum() const -
223 -
224 Returns the maximum progressValue(). -
225 -
226 \sa progressValue(), progressMinimum() -
227*/ -
228int QFutureWatcherBase::progressMaximum() const -
229{ -
230 return futureInterface().progressMaximum();
executed: return futureInterface().progressMaximum();
Execution Count:6
6
231} -
232 -
233/*! \fn QString QFutureWatcher::progressText() const -
234 -
235 Returns the (optional) textual representation of the progress as reported -
236 by the asynchronous computation. -
237 -
238 Be aware that not all computations provide a textual representation of the -
239 progress, and as such, this function may return an empty string. -
240*/ -
241QString QFutureWatcherBase::progressText() const -
242{ -
243 return futureInterface().progressText();
executed: return futureInterface().progressText();
Execution Count:6
6
244} -
245 -
246/*! \fn bool QFutureWatcher::isStarted() const -
247 -
248 Returns true if the asynchronous computation represented by the future() -
249 has been started; otherwise returns false. -
250*/ -
251bool QFutureWatcherBase::isStarted() const -
252{ -
253 return futureInterface().queryState(QFutureInterfaceBase::Started);
executed: return futureInterface().queryState(QFutureInterfaceBase::Started);
Execution Count:6
6
254} -
255 -
256/*! \fn bool QFutureWatcher::isFinished() const -
257 -
258 Returns true if the asynchronous computation represented by the future() -
259 has finished; otherwise returns false. -
260*/ -
261bool QFutureWatcherBase::isFinished() const -
262{ -
263 Q_D(const QFutureWatcherBase);
executed (the execution status of this line is deduced): const QFutureWatcherBasePrivate * const d = d_func();
-
264 return d->finished;
executed: return d->finished;
Execution Count:10
10
265} -
266 -
267/*! \fn bool QFutureWatcher::isRunning() const -
268 -
269 Returns true if the asynchronous computation represented by the future() -
270 is currently running; otherwise returns false. -
271*/ -
272bool QFutureWatcherBase::isRunning() const -
273{ -
274 return futureInterface().queryState(QFutureInterfaceBase::Running);
executed: return futureInterface().queryState(QFutureInterfaceBase::Running);
Execution Count:6
6
275} -
276 -
277/*! \fn bool QFutureWatcher::isCanceled() const -
278 -
279 Returns true if the asynchronous computation has been canceled with the -
280 cancel() function; otherwise returns false. -
281 -
282 Be aware that the computation may still be running even though this -
283 function returns true. See cancel() for more details. -
284*/ -
285bool QFutureWatcherBase::isCanceled() const -
286{ -
287 return futureInterface().queryState(QFutureInterfaceBase::Canceled);
executed: return futureInterface().queryState(QFutureInterfaceBase::Canceled);
Execution Count:6
6
288} -
289 -
290/*! \fn bool QFutureWatcher::isPaused() const -
291 -
292 Returns true if the asynchronous computation has been paused with the -
293 pause() function; otherwise returns false. -
294 -
295 Be aware that the computation may still be running even though this -
296 function returns true. See setPaused() for more details. -
297 -
298 \sa setPaused(), togglePaused() -
299*/ -
300bool QFutureWatcherBase::isPaused() const -
301{ -
302 return futureInterface().queryState(QFutureInterfaceBase::Paused);
executed: return futureInterface().queryState(QFutureInterfaceBase::Paused);
Execution Count:6
6
303} -
304 -
305/*! \fn void QFutureWatcher::waitForFinished() -
306 -
307 Waits for the asynchronous computation to finish (including cancel()ed -
308 computations). -
309*/ -
310void QFutureWatcherBase::waitForFinished() -
311{ -
312 futureInterface().waitForFinished();
executed (the execution status of this line is deduced): futureInterface().waitForFinished();
-
313}
executed: }
Execution Count:4
4
314 -
315/*! \fn void QFutureWatcher::setPendingResultsLimit(int limit) -
316 -
317 The setPendingResultsLimit() provides throttling control. When the number -
318 of pending resultReadyAt() or resultsReadyAt() signals exceeds the -
319 \a limit, the computation represented by the future will be throttled -
320 automatically. The computation will resume once the number of pending -
321 signals drops below the \a limit. -
322*/ -
323 -
324bool QFutureWatcherBase::event(QEvent *event) -
325{ -
326 Q_D(QFutureWatcherBase);
executed (the execution status of this line is deduced): QFutureWatcherBasePrivate * const d = d_func();
-
327 if (event->type() == QEvent::FutureCallOut) {
partially evaluated: event->type() == QEvent::FutureCallOut
TRUEFALSE
yes
Evaluation Count:1521
no
Evaluation Count:0
0-1521
328 QFutureCallOutEvent *callOutEvent = static_cast<QFutureCallOutEvent *>(event);
executed (the execution status of this line is deduced): QFutureCallOutEvent *callOutEvent = static_cast<QFutureCallOutEvent *>(event);
-
329 -
330 if (futureInterface().isPaused()) {
evaluated: futureInterface().isPaused()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1515
6-1515
331 d->pendingCallOutEvents.append(callOutEvent->clone());
executed (the execution status of this line is deduced): d->pendingCallOutEvents.append(callOutEvent->clone());
-
332 return true;
executed: return true;
Execution Count:6
6
333 } -
334 -
335 if (callOutEvent->callOutType == QFutureCallOutEvent::Resumed
evaluated: callOutEvent->callOutType == QFutureCallOutEvent::Resumed
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1514
1-1514
336 && !d->pendingCallOutEvents.isEmpty()) {
partially evaluated: !d->pendingCallOutEvents.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
337 // send the resume -
338 d->sendCallOutEvent(callOutEvent);
executed (the execution status of this line is deduced): d->sendCallOutEvent(callOutEvent);
-
339 -
340 // next send all pending call outs -
341 for (int i = 0; i < d->pendingCallOutEvents.count(); ++i)
evaluated: i < d->pendingCallOutEvents.count()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1
1-6
342 d->sendCallOutEvent(d->pendingCallOutEvents.at(i));
executed: d->sendCallOutEvent(d->pendingCallOutEvents.at(i));
Execution Count:6
6
343 qDeleteAll(d->pendingCallOutEvents);
executed (the execution status of this line is deduced): qDeleteAll(d->pendingCallOutEvents);
-
344 d->pendingCallOutEvents.clear();
executed (the execution status of this line is deduced): d->pendingCallOutEvents.clear();
-
345 } else {
executed: }
Execution Count:1
1
346 d->sendCallOutEvent(callOutEvent);
executed (the execution status of this line is deduced): d->sendCallOutEvent(callOutEvent);
-
347 }
executed: }
Execution Count:1514
1514
348 return true;
executed: return true;
Execution Count:1515
1515
349 } -
350 return QObject::event(event);
never executed: return QObject::event(event);
0
351} -
352 -
353void QFutureWatcherBase::setPendingResultsLimit(int limit) -
354{ -
355 Q_D(QFutureWatcherBase);
never executed (the execution status of this line is deduced): QFutureWatcherBasePrivate * const d = d_func();
-
356 d->maximumPendingResultsReady = limit;
never executed (the execution status of this line is deduced): d->maximumPendingResultsReady = limit;
-
357}
never executed: }
0
358 -
359void QFutureWatcherBase::connectNotify(const QMetaMethod &signal) -
360{ -
361 Q_D(QFutureWatcherBase);
executed (the execution status of this line is deduced): QFutureWatcherBasePrivate * const d = d_func();
-
362 static const QMetaMethod resultReadyAtSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::resultReadyAt); -
363 if (signal == resultReadyAtSignal)
evaluated: signal == resultReadyAtSignal
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:23
19-23
364 d->resultAtConnected.ref();
executed: d->resultAtConnected.ref();
Execution Count:19
19
365#ifndef QT_NO_DEBUG -
366 static const QMetaMethod finishedSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::finished); -
367 if (signal == finishedSignal) { -
368 if (futureInterface().isRunning()) { -
369 //connections should be established before calling stFuture to avoid race. -
370 // (The future could finish before the connection is made.) -
371 qWarning("QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race"); -
372 } -
373 } -
374#endif -
375}
executed: }
Execution Count:42
42
376 -
377void QFutureWatcherBase::disconnectNotify(const QMetaMethod &signal) -
378{ -
379 Q_D(QFutureWatcherBase);
executed (the execution status of this line is deduced): QFutureWatcherBasePrivate * const d = d_func();
-
380 static const QMetaMethod resultReadyAtSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::resultReadyAt); -
381 if (signal == resultReadyAtSignal)
evaluated: signal == resultReadyAtSignal
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:15
15-16
382 d->resultAtConnected.deref();
executed: d->resultAtConnected.deref();
Execution Count:16
16
383}
executed: }
Execution Count:31
31
384 -
385/*! -
386 \internal -
387*/ -
388QFutureWatcherBasePrivate::QFutureWatcherBasePrivate() -
389 : maximumPendingResultsReady(QThread::idealThreadCount() * 2), -
390 resultAtConnected(0) -
391{ }
executed: }
Execution Count:22
22
392 -
393/*! -
394 \internal -
395*/ -
396void QFutureWatcherBase::connectOutputInterface() -
397{ -
398 futureInterface().d->connectOutputInterface(d_func());
executed (the execution status of this line is deduced): futureInterface().d->connectOutputInterface(d_func());
-
399}
executed: }
Execution Count:28
28
400 -
401/*! -
402 \internal -
403*/ -
404void QFutureWatcherBase::disconnectOutputInterface(bool pendingAssignment) -
405{ -
406 if (pendingAssignment) {
evaluated: pendingAssignment
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:22
22-28
407 Q_D(QFutureWatcherBase);
executed (the execution status of this line is deduced): QFutureWatcherBasePrivate * const d = d_func();
-
408 d->pendingResultsReady.store(0);
executed (the execution status of this line is deduced): d->pendingResultsReady.store(0);
-
409 qDeleteAll(d->pendingCallOutEvents);
executed (the execution status of this line is deduced): qDeleteAll(d->pendingCallOutEvents);
-
410 d->pendingCallOutEvents.clear();
executed (the execution status of this line is deduced): d->pendingCallOutEvents.clear();
-
411 d->finished = false;
executed (the execution status of this line is deduced): d->finished = false;
-
412 }
executed: }
Execution Count:28
28
413 -
414 futureInterface().d->disconnectOutputInterface(d_func());
executed (the execution status of this line is deduced): futureInterface().d->disconnectOutputInterface(d_func());
-
415}
executed: }
Execution Count:50
50
416 -
417void QFutureWatcherBasePrivate::postCallOutEvent(const QFutureCallOutEvent &callOutEvent) -
418{ -
419 Q_Q(QFutureWatcherBase);
executed (the execution status of this line is deduced): QFutureWatcherBase * const q = q_func();
-
420 -
421 if (callOutEvent.callOutType == QFutureCallOutEvent::ResultsReady) {
evaluated: callOutEvent.callOutType == QFutureCallOutEvent::ResultsReady
TRUEFALSE
yes
Evaluation Count:1424
yes
Evaluation Count:153
153-1424
422 if (pendingResultsReady.fetchAndAddRelaxed(1) >= maximumPendingResultsReady)
evaluated: pendingResultsReady.fetchAndAddRelaxed(1) >= maximumPendingResultsReady
TRUEFALSE
yes
Evaluation Count:1355
yes
Evaluation Count:69
69-1355
423 q->futureInterface().d->internal_setThrottled(true);
executed: q->futureInterface().d->internal_setThrottled(true);
Execution Count:1355
1355
424 }
executed: }
Execution Count:1424
1424
425 -
426 QCoreApplication::postEvent(q, callOutEvent.clone());
executed (the execution status of this line is deduced): QCoreApplication::postEvent(q, callOutEvent.clone());
-
427}
executed: }
Execution Count:1577
1577
428 -
429void QFutureWatcherBasePrivate::callOutInterfaceDisconnected() -
430{ -
431 QCoreApplication::removePostedEvents(q_func(), QEvent::FutureCallOut);
executed (the execution status of this line is deduced): QCoreApplication::removePostedEvents(q_func(), QEvent::FutureCallOut);
-
432}
executed: }
Execution Count:28
28
433 -
434void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event) -
435{ -
436 Q_Q(QFutureWatcherBase);
executed (the execution status of this line is deduced): QFutureWatcherBase * const q = q_func();
-
437 -
438 switch (event->callOutType) { -
439 case QFutureCallOutEvent::Started: -
440 emit q->started();
executed (the execution status of this line is deduced): q->started();
-
441 break;
executed: break;
Execution Count:20
20
442 case QFutureCallOutEvent::Finished: -
443 finished = true;
executed (the execution status of this line is deduced): finished = true;
-
444 emit q->finished();
executed (the execution status of this line is deduced): q->finished();
-
445 break;
executed: break;
Execution Count:17
17
446 case QFutureCallOutEvent::Canceled: -
447 pendingResultsReady.store(0);
executed (the execution status of this line is deduced): pendingResultsReady.store(0);
-
448 emit q->canceled();
executed (the execution status of this line is deduced): q->canceled();
-
449 break;
executed: break;
Execution Count:5
5
450 case QFutureCallOutEvent::Paused: -
451 if (q->futureInterface().isCanceled())
partially evaluated: q->futureInterface().isCanceled()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
452 break;
never executed: break;
0
453 emit q->paused();
executed (the execution status of this line is deduced): q->paused();
-
454 break;
executed: break;
Execution Count:1
1
455 case QFutureCallOutEvent::Resumed: -
456 if (q->futureInterface().isCanceled())
partially evaluated: q->futureInterface().isCanceled()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
457 break;
never executed: break;
0
458 emit q->resumed();
executed (the execution status of this line is deduced): q->resumed();
-
459 break;
executed: break;
Execution Count:1
1
460 case QFutureCallOutEvent::ResultsReady: { -
461 if (q->futureInterface().isCanceled())
evaluated: q->futureInterface().isCanceled()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1418
1-1418
462 break;
executed: break;
Execution Count:1
1
463 -
464 if (pendingResultsReady.fetchAndAddRelaxed(-1) <= maximumPendingResultsReady)
evaluated: pendingResultsReady.fetchAndAddRelaxed(-1) <= maximumPendingResultsReady
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:1355
63-1355
465 q->futureInterface().setThrottled(false);
executed: q->futureInterface().setThrottled(false);
Execution Count:63
63
466 -
467 const int beginIndex = event->index1;
executed (the execution status of this line is deduced): const int beginIndex = event->index1;
-
468 const int endIndex = event->index2;
executed (the execution status of this line is deduced): const int endIndex = event->index2;
-
469 -
470 emit q->resultsReadyAt(beginIndex, endIndex);
executed (the execution status of this line is deduced): q->resultsReadyAt(beginIndex, endIndex);
-
471 -
472 if (resultAtConnected.load() <= 0)
evaluated: resultAtConnected.load() <= 0
TRUEFALSE
yes
Evaluation Count:1001
yes
Evaluation Count:417
417-1001
473 break;
executed: break;
Execution Count:1001
1001
474 -
475 for (int i = beginIndex; i < endIndex; ++i)
evaluated: i < endIndex
TRUEFALSE
yes
Evaluation Count:15008
yes
Evaluation Count:417
417-15008
476 emit q->resultReadyAt(i);
executed: q->resultReadyAt(i);
Execution Count:15008
15008
477 -
478 } break;
executed: break;
Execution Count:417
417
479 case QFutureCallOutEvent::Progress: -
480 if (q->futureInterface().isCanceled())
evaluated: q->futureInterface().isCanceled()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:32
5-32
481 break;
executed: break;
Execution Count:5
5
482 -
483 emit q->progressValueChanged(event->index1);
executed (the execution status of this line is deduced): q->progressValueChanged(event->index1);
-
484 if (!event->text.isNull()) // ###
evaluated: !event->text.isNull()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:28
4-28
485 q->progressTextChanged(event->text);
executed: q->progressTextChanged(event->text);
Execution Count:4
4
486 break;
executed: break;
Execution Count:32
32
487 case QFutureCallOutEvent::ProgressRange: -
488 emit q->progressRangeChanged(event->index1, event->index2);
executed (the execution status of this line is deduced): q->progressRangeChanged(event->index1, event->index2);
-
489 break;
executed: break;
Execution Count:21
21
490 default: break;
never executed: break;
0
491 } -
492}
executed: }
Execution Count:1521
1521
493 -
494 -
495/*! \fn const T &QFutureWatcher::result() const -
496 -
497 Returns the first result in the future(). If the result is not immediately -
498 available, this function will block and wait for the result to become -
499 available. This is a convenience method for calling resultAt(0). -
500 -
501 \sa resultAt() -
502*/ -
503 -
504/*! \fn const T &QFutureWatcher::resultAt(int index) const -
505 -
506 Returns the result at \a index in the future(). If the result is not -
507 immediately available, this function will block and wait for the result to -
508 become available. -
509 -
510 \sa result() -
511*/ -
512 -
513/*! \fn void QFutureWatcher::setFuture(const QFuture<T> &future) -
514 -
515 Starts watching the given \a future. -
516 -
517 One of the signals might be emitted for the current state of the -
518 \a future. For example, if the future is already stopped, the -
519 finished signal will be emitted. -
520 -
521 To avoid a race condition, it is important to call this function -
522 \e after doing the connections. -
523*/ -
524 -
525/*! \fn QFuture<T> QFutureWatcher::future() const -
526 -
527 Returns the watched future. -
528*/ -
529 -
530/*! \fn void QFutureWatcher::started() -
531 -
532 This signal is emitted when this QFutureWatcher starts watching the future -
533 set with setFuture(). -
534*/ -
535 -
536/*! -
537 \fn void QFutureWatcher::finished() -
538 This signal is emitted when the watched future finishes. -
539*/ -
540 -
541/*! -
542 \fn void QFutureWatcher::canceled() -
543 This signal is emitted if the watched future is canceled. -
544*/ -
545 -
546/*! \fn void QFutureWatcher::paused() -
547 This signal is emitted when the watched future is paused. -
548*/ -
549 -
550/*! \fn void QFutureWatcher::resumed() -
551 This signal is emitted when the watched future is resumed. -
552*/ -
553 -
554/*! -
555 \fn void QFutureWatcher::progressRangeChanged(int minimum, int maximum) -
556 -
557 The progress range for the watched future has changed to \a minimum and -
558 \a maximum -
559*/ -
560 -
561/*! -
562 \fn void QFutureWatcher::progressValueChanged(int progressValue) -
563 -
564 This signal is emitted when the watched future reports progress, -
565 \a progressValue gives the current progress. In order to avoid overloading -
566 the GUI event loop, QFutureWatcher limits the progress signal emission -
567 rate. This means that listeners connected to this slot might not get all -
568 progress reports the future makes. The last progress update (where -
569 \a progressValue equals the maximum value) will always be delivered. -
570*/ -
571 -
572/*! \fn void QFutureWatcher::progressTextChanged(const QString &progressText) -
573 -
574 This signal is emitted when the watched future reports textual progress -
575 information, \a progressText. -
576*/ -
577 -
578/*! -
579 \fn void QFutureWatcher::resultReadyAt(int index) -
580 -
581 This signal is emitted when the watched future reports a ready result at -
582 \a index. If the future reports multiple results, the index will indicate -
583 which one it is. Results can be reported out-of-order. To get the result, -
584 call future().result(index); -
585*/ -
586 -
587/*! -
588 \fn void QFutureWatcher::resultsReadyAt(int beginIndex, int endIndex); -
589 -
590 This signal is emitted when the watched future reports ready results. -
591 The results are indexed from \a beginIndex to \a endIndex. -
592 -
593*/ -
594 -
595QT_END_NAMESPACE -
596 -
597#endif // QT_NO_QFUTURE -
598 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial