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

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