qfuturewatcher.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9