Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | enum { | - |
9 | MaxProgressEmitsPerSecond = 25 | - |
10 | }; | - |
11 | | - |
12 | QFutureInterfaceBase::QFutureInterfaceBase(State initialState) | - |
13 | : d(new QFutureInterfaceBasePrivate(initialState)) | - |
14 | { } executed: } Execution Count:584761 | 584761 |
15 | | - |
16 | QFutureInterfaceBase::QFutureInterfaceBase(const QFutureInterfaceBase &other) | - |
17 | : d(other.d) | - |
18 | { | - |
19 | d->refCount.ref(); | - |
20 | } executed: } Execution Count:615827 | 615827 |
21 | | - |
22 | QFutureInterfaceBase::~QFutureInterfaceBase() | - |
23 | { | - |
24 | if (!d->refCount.deref()) evaluated: !d->refCount.deref() yes Evaluation Count:585709 | yes Evaluation Count:615878 |
| 585709-615878 |
25 | delete d; executed: delete d; Execution Count:585165 | 585165 |
26 | } executed: } Execution Count:1195600 | 1195600 |
27 | | - |
28 | void QFutureInterfaceBase::cancel() | - |
29 | { | - |
30 | QMutexLocker locker(&d->m_mutex); | - |
31 | if (d->state & Canceled) evaluated: d->state & Canceled yes Evaluation Count:5 | yes Evaluation Count:1112 |
| 5-1112 |
32 | return; executed: return; Execution Count:5 | 5 |
33 | | - |
34 | d->state = State((d->state & ~Paused) | Canceled); | - |
35 | d->waitCondition.wakeAll(); | - |
36 | d->pausedWaitCondition.wakeAll(); | - |
37 | d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Canceled)); | - |
38 | } executed: } Execution Count:1112 | 1112 |
39 | | - |
40 | void QFutureInterfaceBase::setPaused(bool paused) | - |
41 | { | - |
42 | QMutexLocker locker(&d->m_mutex); | - |
43 | if (paused) { evaluated: paused yes Evaluation Count:9 | yes Evaluation Count:9 |
| 9 |
44 | d->state = State(d->state | Paused); | - |
45 | d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Paused)); | - |
46 | } else { executed: } Execution Count:9 | 9 |
47 | d->state = State(d->state & ~Paused); | - |
48 | d->pausedWaitCondition.wakeAll(); | - |
49 | d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Resumed)); | - |
50 | } executed: } Execution Count:9 | 9 |
51 | } | - |
52 | | - |
53 | void QFutureInterfaceBase::togglePaused() | - |
54 | { | - |
55 | QMutexLocker locker(&d->m_mutex); | - |
56 | if (d->state & Paused) { evaluated: d->state & Paused yes Evaluation Count:1 | yes Evaluation Count:7 |
| 1-7 |
57 | d->state = State(d->state & ~Paused); | - |
58 | d->pausedWaitCondition.wakeAll(); | - |
59 | d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Resumed)); | - |
60 | } else { executed: } Execution Count:1 | 1 |
61 | d->state = State(d->state | Paused); | - |
62 | d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Paused)); | - |
63 | } executed: } Execution Count:7 | 7 |
64 | } | - |
65 | | - |
66 | void QFutureInterfaceBase::setThrottled(bool enable) | - |
67 | { | - |
68 | | - |
69 | if ((enable && (d->state & Throttled)) || (!enable && !(d->state & Throttled))) evaluated: enable yes Evaluation Count:2 | yes Evaluation Count:64 |
partially evaluated: (d->state & Throttled) no Evaluation Count:0 | yes Evaluation Count:2 |
evaluated: !enable yes Evaluation Count:64 | yes Evaluation Count:2 |
evaluated: !(d->state & Throttled) yes Evaluation Count:60 | yes Evaluation Count:4 |
| 0-64 |
70 | return; executed: return; Execution Count:60 | 60 |
71 | | - |
72 | | - |
73 | QMutexLocker lock(&d->m_mutex); | - |
74 | if (enable) { evaluated: enable yes Evaluation Count:2 | yes Evaluation Count:4 |
| 2-4 |
75 | d->state = State(d->state | Throttled); | - |
76 | } else { executed: } Execution Count:2 | 2 |
77 | d->state = State(d->state & ~Throttled); | - |
78 | if (!(d->state & Paused)) partially evaluated: !(d->state & Paused) yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
79 | d->pausedWaitCondition.wakeAll(); executed: d->pausedWaitCondition.wakeAll(); Execution Count:4 | 4 |
80 | } executed: } Execution Count:4 | 4 |
81 | } | - |
82 | | - |
83 | | - |
84 | bool QFutureInterfaceBase::isRunning() const | - |
85 | { | - |
86 | return queryState(Running); executed: return queryState(Running); Execution Count:47 | 47 |
87 | } | - |
88 | | - |
89 | bool QFutureInterfaceBase::isStarted() const | - |
90 | { | - |
91 | return queryState(Started); executed: return queryState(Started); Execution Count:26 | 26 |
92 | } | - |
93 | | - |
94 | bool QFutureInterfaceBase::isCanceled() const | - |
95 | { | - |
96 | return queryState(Canceled); executed: return queryState(Canceled); Execution Count:1278110 | 1278110 |
97 | } | - |
98 | | - |
99 | bool QFutureInterfaceBase::isFinished() const | - |
100 | { | - |
101 | return queryState(Finished); executed: return queryState(Finished); Execution Count:166 | 166 |
102 | } | - |
103 | | - |
104 | bool QFutureInterfaceBase::isPaused() const | - |
105 | { | - |
106 | return queryState(Paused); executed: return queryState(Paused); Execution Count:50475 | 50475 |
107 | } | - |
108 | | - |
109 | bool QFutureInterfaceBase::isThrottled() const | - |
110 | { | - |
111 | return queryState(Throttled); executed: return queryState(Throttled); Execution Count:7 | 7 |
112 | } | - |
113 | | - |
114 | bool QFutureInterfaceBase::isResultReadyAt(int index) const | - |
115 | { | - |
116 | QMutexLocker lock(&d->m_mutex); | - |
117 | return d->internal_isResultReadyAt(index); executed: return d->internal_isResultReadyAt(index); Execution Count:15004 | 15004 |
118 | } | - |
119 | | - |
120 | bool QFutureInterfaceBase::waitForNextResult() | - |
121 | { | - |
122 | QMutexLocker lock(&d->m_mutex); | - |
123 | return d->internal_waitForNextResult(); never executed: return d->internal_waitForNextResult(); | 0 |
124 | } | - |
125 | | - |
126 | void QFutureInterfaceBase::waitForResume() | - |
127 | { | - |
128 | | - |
129 | if ((d->state & Paused) == false || (d->state & Canceled)) partially evaluated: (d->state & Paused) == false yes Evaluation Count:23984 | no Evaluation Count:0 |
never evaluated: (d->state & Canceled) | 0-23984 |
130 | return; executed: return; Execution Count:23857 | 23857 |
131 | | - |
132 | QMutexLocker lock(&d->m_mutex); | - |
133 | if ((d->state & Paused) == false || (d->state & Canceled)) never evaluated: (d->state & Paused) == false never evaluated: (d->state & Canceled) | 0 |
134 | return; | 0 |
135 | | - |
136 | | - |
137 | QThreadPool::globalInstance()->releaseThread(); | - |
138 | | - |
139 | d->pausedWaitCondition.wait(&d->m_mutex); | - |
140 | | - |
141 | QThreadPool::globalInstance()->reserveThread(); | - |
142 | } | 0 |
143 | | - |
144 | int QFutureInterfaceBase::progressValue() const | - |
145 | { | - |
146 | return d->m_progressValue; executed: return d->m_progressValue; Execution Count:17 | 17 |
147 | } | - |
148 | | - |
149 | int QFutureInterfaceBase::progressMinimum() const | - |
150 | { | - |
151 | return d->m_progressMinimum; executed: return d->m_progressMinimum; Execution Count:12 | 12 |
152 | } | - |
153 | | - |
154 | int QFutureInterfaceBase::progressMaximum() const | - |
155 | { | - |
156 | return d->m_progressMaximum; executed: return d->m_progressMaximum; Execution Count:12 | 12 |
157 | } | - |
158 | | - |
159 | int QFutureInterfaceBase::resultCount() const | - |
160 | { | - |
161 | QMutexLocker lock(&d->m_mutex); | - |
162 | return d->internal_resultCount(); executed: return d->internal_resultCount(); Execution Count:3915 | 3915 |
163 | } | - |
164 | | - |
165 | QString QFutureInterfaceBase::progressText() const | - |
166 | { | - |
167 | QMutexLocker locker(&d->m_mutex); | - |
168 | return d->m_progressText; executed: return d->m_progressText; Execution Count:15 | 15 |
169 | } | - |
170 | | - |
171 | bool QFutureInterfaceBase::isProgressUpdateNeeded() const | - |
172 | { | - |
173 | QMutexLocker locker(&d->m_mutex); | - |
174 | return !d->progressTime.isValid() || (d->progressTime.elapsed() > (1000 / MaxProgressEmitsPerSecond)); executed: return !d->progressTime.isValid() || (d->progressTime.elapsed() > (1000 / MaxProgressEmitsPerSecond)); Execution Count:120 | 120 |
175 | } | - |
176 | | - |
177 | void QFutureInterfaceBase::reportStarted() | - |
178 | { | - |
179 | QMutexLocker locker(&d->m_mutex); | - |
180 | if ((d->state & Started) || (d->state & Canceled) || (d->state & Finished)) partially evaluated: (d->state & Started) no Evaluation Count:0 | yes Evaluation Count:583729 |
partially evaluated: (d->state & Canceled) no Evaluation Count:0 | yes Evaluation Count:584359 |
partially evaluated: (d->state & Finished) no Evaluation Count:0 | yes Evaluation Count:584624 |
| 0-584624 |
181 | return; | 0 |
182 | | - |
183 | d->setState(State(Started | Running)); | - |
184 | d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Started)); | - |
185 | } executed: } Execution Count:582142 | 582142 |
186 | | - |
187 | void QFutureInterfaceBase::reportCanceled() | - |
188 | { | - |
189 | cancel(); | - |
190 | } executed: } Execution Count:3 | 3 |
191 | | - |
192 | | - |
193 | void QFutureInterfaceBase::reportException(const QException &exception) | - |
194 | { | - |
195 | QMutexLocker locker(&d->m_mutex); | - |
196 | if ((d->state & Canceled) || (d->state & Finished)) evaluated: (d->state & Canceled) yes Evaluation Count:9 | yes Evaluation Count:13 |
partially evaluated: (d->state & Finished) no Evaluation Count:0 | yes Evaluation Count:13 |
| 0-13 |
197 | return; executed: return; Execution Count:9 | 9 |
198 | | - |
199 | d->m_exceptionStore.setException(exception); | - |
200 | d->state = State(d->state | Canceled); | - |
201 | d->waitCondition.wakeAll(); | - |
202 | d->pausedWaitCondition.wakeAll(); | - |
203 | d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Canceled)); | - |
204 | } executed: } Execution Count:13 | 13 |
205 | | - |
206 | | - |
207 | void QFutureInterfaceBase::reportFinished() | - |
208 | { | - |
209 | QMutexLocker locker(&d->m_mutex); | - |
210 | if (!(d->state & Finished)) { partially evaluated: !(d->state & Finished) yes Evaluation Count:582914 | no Evaluation Count:0 |
| 0-582914 |
211 | d->state = State((d->state & ~Running) | Finished); | - |
212 | d->waitCondition.wakeAll(); | - |
213 | d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Finished)); | - |
214 | } executed: } Execution Count:581511 | 581511 |
215 | } executed: } Execution Count:582066 | 582066 |
216 | | - |
217 | void QFutureInterfaceBase::setExpectedResultCount(int resultCount) | - |
218 | { | - |
219 | if (d->manualProgress == false) never evaluated: d->manualProgress == false | 0 |
220 | setProgressRange(0, resultCount); never executed: setProgressRange(0, resultCount); | 0 |
221 | d->m_expectedResultCount = resultCount; | - |
222 | } | 0 |
223 | | - |
224 | int QFutureInterfaceBase::expectedResultCount() | - |
225 | { | - |
226 | return d->m_expectedResultCount; never executed: return d->m_expectedResultCount; | 0 |
227 | } | - |
228 | | - |
229 | bool QFutureInterfaceBase::queryState(State state) const | - |
230 | { | - |
231 | return (d->state & state); executed: return (d->state & state); Execution Count:1845194 | 1845194 |
232 | } | - |
233 | | - |
234 | void QFutureInterfaceBase::waitForResult(int resultIndex) | - |
235 | { | - |
236 | d->m_exceptionStore.throwPossibleException(); | - |
237 | | - |
238 | QMutexLocker lock(&d->m_mutex); | - |
239 | if (!(d->state & Running)) evaluated: !(d->state & Running) yes Evaluation Count:15498 | yes Evaluation Count:263889 |
| 15498-263889 |
240 | return; executed: return; Execution Count:15498 | 15498 |
241 | lock.unlock(); | - |
242 | | - |
243 | | - |
244 | | - |
245 | QThreadPool::globalInstance()->d_func()->stealRunnable(d->runnable); | - |
246 | | - |
247 | lock.relock(); | - |
248 | | - |
249 | if (!(d->state & Running)) evaluated: !(d->state & Running) yes Evaluation Count:260361 | yes Evaluation Count:3744 |
| 3744-260361 |
250 | return; executed: return; Execution Count:260151 | 260151 |
251 | | - |
252 | const int waitIndex = (resultIndex == -1) ? 2147483647 : resultIndex; evaluated: (resultIndex == -1) yes Evaluation Count:86 | yes Evaluation Count:3658 |
| 86-3658 |
253 | while ((d->state & Running) && d->internal_isResultReadyAt(waitIndex) == false) evaluated: (d->state & Running) yes Evaluation Count:3904 | yes Evaluation Count:370 |
evaluated: d->internal_isResultReadyAt(waitIndex) == false yes Evaluation Count:530 | yes Evaluation Count:3374 |
| 370-3904 |
254 | d->waitCondition.wait(&d->m_mutex); executed: d->waitCondition.wait(&d->m_mutex); Execution Count:530 | 530 |
255 | | - |
256 | d->m_exceptionStore.throwPossibleException(); | - |
257 | } executed: } Execution Count:3744 | 3744 |
258 | | - |
259 | void QFutureInterfaceBase::waitForFinished() | - |
260 | { | - |
261 | QMutexLocker lock(&d->m_mutex); | - |
262 | const bool alreadyFinished = !(d->state & Running); | - |
263 | lock.unlock(); | - |
264 | | - |
265 | if (!alreadyFinished) { evaluated: !alreadyFinished yes Evaluation Count:302294 | yes Evaluation Count:1551 |
| 1551-302294 |
266 | QThreadPool::globalInstance()->d_func()->stealRunnable(d->runnable); | - |
267 | | - |
268 | lock.relock(); | - |
269 | | - |
270 | while (d->state & Running) evaluated: d->state & Running yes Evaluation Count:40439 | yes Evaluation Count:302101 |
| 40439-302101 |
271 | d->waitCondition.wait(&d->m_mutex); executed: d->waitCondition.wait(&d->m_mutex); Execution Count:40439 | 40439 |
272 | } executed: } Execution Count:301999 | 301999 |
273 | | - |
274 | d->m_exceptionStore.throwPossibleException(); | - |
275 | } executed: } Execution Count:303338 | 303338 |
276 | | - |
277 | void QFutureInterfaceBase::reportResultsReady(int beginIndex, int endIndex) | - |
278 | { | - |
279 | if ((d->state & Canceled) || (d->state & Finished) || beginIndex == endIndex) partially evaluated: (d->state & Canceled) no Evaluation Count:0 | yes Evaluation Count:263547 |
partially evaluated: (d->state & Finished) no Evaluation Count:0 | yes Evaluation Count:263832 |
evaluated: beginIndex == endIndex yes Evaluation Count:564 | yes Evaluation Count:263446 |
| 0-263832 |
280 | return; executed: return; Execution Count:564 | 564 |
281 | | - |
282 | d->waitCondition.wakeAll(); | - |
283 | | - |
284 | if (d->manualProgress == false) { evaluated: d->manualProgress == false yes Evaluation Count:261386 | yes Evaluation Count:1918 |
| 1918-261386 |
285 | if (d->internal_updateProgress(d->m_progressValue + endIndex - beginIndex) == false) { evaluated: d->internal_updateProgress(d->m_progressValue + endIndex - beginIndex) == false yes Evaluation Count:1131 | yes Evaluation Count:259799 |
| 1131-259799 |
286 | d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::ResultsReady, | - |
287 | beginIndex, | - |
288 | endIndex)); | - |
289 | return; executed: return; Execution Count:1131 | 1131 |
290 | } | - |
291 | | - |
292 | d->sendCallOuts(QFutureCallOutEvent(QFutureCallOutEvent::Progress, | - |
293 | d->m_progressValue, | - |
294 | d->m_progressText), | - |
295 | QFutureCallOutEvent(QFutureCallOutEvent::ResultsReady, | - |
296 | beginIndex, | - |
297 | endIndex)); | - |
298 | return; executed: return; Execution Count:258869 | 258869 |
299 | } | - |
300 | d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::ResultsReady, beginIndex, endIndex)); | - |
301 | } executed: } Execution Count:1918 | 1918 |
302 | | - |
303 | void QFutureInterfaceBase::setRunnable(QRunnable *runnable) | - |
304 | { | - |
305 | d->runnable = runnable; | - |
306 | } executed: } Execution Count:523066 | 523066 |
307 | | - |
308 | void QFutureInterfaceBase::setFilterMode(bool enable) | - |
309 | { | - |
310 | QMutexLocker locker(&d->m_mutex); | - |
311 | resultStoreBase().setFilterMode(enable); | - |
312 | } executed: } Execution Count:34 | 34 |
313 | | - |
314 | void QFutureInterfaceBase::setProgressRange(int minimum, int maximum) | - |
315 | { | - |
316 | QMutexLocker locker(&d->m_mutex); | - |
317 | d->m_progressMinimum = minimum; | - |
318 | d->m_progressMaximum = maximum; | - |
319 | d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::ProgressRange, minimum, maximum)); | - |
320 | } executed: } Execution Count:256 | 256 |
321 | | - |
322 | void QFutureInterfaceBase::setProgressValue(int progressValue) | - |
323 | { | - |
324 | setProgressValueAndText(progressValue, QString()); | - |
325 | } executed: } Execution Count:123949 | 123949 |
326 | | - |
327 | void QFutureInterfaceBase::setProgressValueAndText(int progressValue, | - |
328 | const QString &progressText) | - |
329 | { | - |
330 | QMutexLocker locker(&d->m_mutex); | - |
331 | if (d->manualProgress == false) evaluated: d->manualProgress == false yes Evaluation Count:257 | yes Evaluation Count:124162 |
| 257-124162 |
332 | d->manualProgress = true; executed: d->manualProgress = true; Execution Count:257 | 257 |
333 | if (d->m_progressValue >= progressValue) evaluated: d->m_progressValue >= progressValue yes Evaluation Count:6621 | yes Evaluation Count:117798 |
| 6621-117798 |
334 | return; executed: return; Execution Count:6621 | 6621 |
335 | | - |
336 | if ((d->state & Canceled) || (d->state & Finished)) partially evaluated: (d->state & Canceled) no Evaluation Count:0 | yes Evaluation Count:117798 |
partially evaluated: (d->state & Finished) no Evaluation Count:0 | yes Evaluation Count:117798 |
| 0-117798 |
337 | return; | 0 |
338 | | - |
339 | if (d->internal_updateProgress(progressValue, progressText)) { evaluated: d->internal_updateProgress(progressValue, progressText) yes Evaluation Count:467 | yes Evaluation Count:117331 |
| 467-117331 |
340 | d->sendCallOut(QFutureCallOutEvent(QFutureCallOutEvent::Progress, | - |
341 | d->m_progressValue, | - |
342 | d->m_progressText)); | - |
343 | } executed: } Execution Count:467 | 467 |
344 | } executed: } Execution Count:117798 | 117798 |
345 | | - |
346 | QMutex *QFutureInterfaceBase::mutex() const | - |
347 | { | - |
348 | return &d->m_mutex; executed: return &d->m_mutex; Execution Count:539377 | 539377 |
349 | } | - |
350 | | - |
351 | QtPrivate::ExceptionStore &QFutureInterfaceBase::exceptionStore() | - |
352 | { | - |
353 | return d->m_exceptionStore; executed: return d->m_exceptionStore; Execution Count:3 | 3 |
354 | } | - |
355 | | - |
356 | QtPrivate::ResultStoreBase &QFutureInterfaceBase::resultStoreBase() | - |
357 | { | - |
358 | return d->m_results; executed: return d->m_results; Execution Count:523502 | 523502 |
359 | } | - |
360 | | - |
361 | const QtPrivate::ResultStoreBase &QFutureInterfaceBase::resultStoreBase() const | - |
362 | { | - |
363 | return d->m_results; executed: return d->m_results; Execution Count:278546 | 278546 |
364 | } | - |
365 | | - |
366 | QFutureInterfaceBase &QFutureInterfaceBase::operator=(const QFutureInterfaceBase &other) | - |
367 | { | - |
368 | other.d->refCount.ref(); | - |
369 | if (!d->refCount.deref()) evaluated: !d->refCount.deref() yes Evaluation Count:59 | yes Evaluation Count:16 |
| 16-59 |
370 | delete d; executed: delete d; Execution Count:59 | 59 |
371 | d = other.d; | - |
372 | return *this; executed: return *this; Execution Count:75 | 75 |
373 | } | - |
374 | | - |
375 | bool QFutureInterfaceBase::refT() const | - |
376 | { | - |
377 | return d->refCount.refT(); executed: return d->refCount.refT(); Execution Count:548189 | 548189 |
378 | } | - |
379 | | - |
380 | bool QFutureInterfaceBase::derefT() const | - |
381 | { | - |
382 | return d->refCount.derefT(); executed: return d->refCount.derefT(); Execution Count:546892 | 546892 |
383 | } | - |
384 | | - |
385 | QFutureInterfaceBasePrivate::QFutureInterfaceBasePrivate(QFutureInterfaceBase::State initialState) | - |
386 | : refCount(1), m_progressValue(0), m_progressMinimum(0), m_progressMaximum(0), | - |
387 | state(initialState), pendingResults(0), | - |
388 | manualProgress(false), m_expectedResultCount(0), runnable(0) | - |
389 | { | - |
390 | progressTime.invalidate(); | - |
391 | } executed: } Execution Count:585142 | 585142 |
392 | | - |
393 | int QFutureInterfaceBasePrivate::internal_resultCount() const | - |
394 | { | - |
395 | return m_results.count(); executed: return m_results.count(); Execution Count:3915 | 3915 |
396 | } | - |
397 | | - |
398 | bool QFutureInterfaceBasePrivate::internal_isResultReadyAt(int index) const | - |
399 | { | - |
400 | return (m_results.contains(index)); executed: return (m_results.contains(index)); Execution Count:18908 | 18908 |
401 | } | - |
402 | | - |
403 | bool QFutureInterfaceBasePrivate::internal_waitForNextResult() | - |
404 | { | - |
405 | if (m_results.hasNextResult()) never evaluated: m_results.hasNextResult() | 0 |
406 | return true; never executed: return true; | 0 |
407 | | - |
408 | while ((state & QFutureInterfaceBase::Running) && m_results.hasNextResult() == false) never evaluated: (state & QFutureInterfaceBase::Running) never evaluated: m_results.hasNextResult() == false | 0 |
409 | waitCondition.wait(&m_mutex); never executed: waitCondition.wait(&m_mutex); | 0 |
410 | | - |
411 | return (!(state & QFutureInterfaceBase::Canceled) && m_results.hasNextResult()); never executed: return (!(state & QFutureInterfaceBase::Canceled) && m_results.hasNextResult()); | 0 |
412 | } | - |
413 | | - |
414 | bool QFutureInterfaceBasePrivate::internal_updateProgress(int progress, | - |
415 | const QString &progressText) | - |
416 | { | - |
417 | if (m_progressValue >= progress) partially evaluated: m_progressValue >= progress no Evaluation Count:0 | yes Evaluation Count:379008 |
| 0-379008 |
418 | return false; never executed: return false; | 0 |
419 | | - |
420 | m_progressValue = progress; | - |
421 | m_progressText = progressText; | - |
422 | | - |
423 | if (progressTime.isValid() && m_progressValue != m_progressMaximum) evaluated: progressTime.isValid() yes Evaluation Count:118722 | yes Evaluation Count:259547 |
evaluated: m_progressValue != m_progressMaximum yes Evaluation Count:118479 | yes Evaluation Count:243 |
| 243-259547 |
424 | if (progressTime.elapsed() < (1000 / MaxProgressEmitsPerSecond)) evaluated: progressTime.elapsed() < (1000 / MaxProgressEmitsPerSecond) yes Evaluation Count:118462 | yes Evaluation Count:17 |
| 17-118462 |
425 | return false; executed: return false; Execution Count:118462 | 118462 |
426 | | - |
427 | progressTime.start(); | - |
428 | return true; executed: return true; Execution Count:260259 | 260259 |
429 | } | - |
430 | | - |
431 | void QFutureInterfaceBasePrivate::internal_setThrottled(bool enable) | - |
432 | { | - |
433 | | - |
434 | if ((enable && (state & QFutureInterfaceBase::Throttled)) partially evaluated: enable yes Evaluation Count:1355 | no Evaluation Count:0 |
evaluated: (state & QFutureInterfaceBase::Throttled) yes Evaluation Count:1352 | yes Evaluation Count:3 |
| 0-1355 |
435 | || (!enable && !(state & QFutureInterfaceBase::Throttled))) partially evaluated: !enable no Evaluation Count:0 | yes Evaluation Count:3 |
never evaluated: !(state & QFutureInterfaceBase::Throttled) | 0-3 |
436 | return; executed: return; Execution Count:1352 | 1352 |
437 | | - |
438 | | - |
439 | if (enable) { partially evaluated: enable yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
440 | state = QFutureInterfaceBase::State(state | QFutureInterfaceBase::Throttled); | - |
441 | } else { executed: } Execution Count:3 | 3 |
442 | state = QFutureInterfaceBase::State(state & ~QFutureInterfaceBase::Throttled); | - |
443 | if (!(state & QFutureInterfaceBase::Paused)) never evaluated: !(state & QFutureInterfaceBase::Paused) | 0 |
444 | pausedWaitCondition.wakeAll(); never executed: pausedWaitCondition.wakeAll(); | 0 |
445 | } | 0 |
446 | } | - |
447 | | - |
448 | void QFutureInterfaceBasePrivate::sendCallOut(const QFutureCallOutEvent &callOutEvent) | - |
449 | { | - |
450 | if (outputConnections.isEmpty()) evaluated: outputConnections.isEmpty() yes Evaluation Count:1161987 | yes Evaluation Count:1453 |
| 1453-1161987 |
451 | return; executed: return; Execution Count:1159645 | 1159645 |
452 | | - |
453 | for (int i = 0; i < outputConnections.count(); ++i) evaluated: i < outputConnections.count() yes Evaluation Count:1453 | yes Evaluation Count:1453 |
| 1453 |
454 | outputConnections.at(i)->postCallOutEvent(callOutEvent); executed: outputConnections.at(i)->postCallOutEvent(callOutEvent); Execution Count:1453 | 1453 |
455 | } executed: } Execution Count:1453 | 1453 |
456 | | - |
457 | void QFutureInterfaceBasePrivate::sendCallOuts(const QFutureCallOutEvent &callOutEvent1, | - |
458 | const QFutureCallOutEvent &callOutEvent2) | - |
459 | { | - |
460 | if (outputConnections.isEmpty()) evaluated: outputConnections.isEmpty() yes Evaluation Count:260594 | yes Evaluation Count:6 |
| 6-260594 |
461 | return; executed: return; Execution Count:259698 | 259698 |
462 | | - |
463 | for (int i = 0; i < outputConnections.count(); ++i) { evaluated: i < outputConnections.count() yes Evaluation Count:6 | yes Evaluation Count:6 |
| 6 |
464 | QFutureCallOutInterface *interface = outputConnections.at(i); | - |
465 | interface->postCallOutEvent(callOutEvent1); | - |
466 | interface->postCallOutEvent(callOutEvent2); | - |
467 | } executed: } Execution Count:6 | 6 |
468 | } executed: } Execution Count:6 | 6 |
469 | | - |
470 | | - |
471 | | - |
472 | | - |
473 | | - |
474 | void QFutureInterfaceBasePrivate::connectOutputInterface(QFutureCallOutInterface *interface) | - |
475 | { | - |
476 | QMutexLocker locker(&m_mutex); | - |
477 | | - |
478 | if (state & QFutureInterfaceBase::Started) { partially evaluated: state & QFutureInterfaceBase::Started yes Evaluation Count:28 | no Evaluation Count:0 |
| 0-28 |
479 | interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Started)); | - |
480 | interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::ProgressRange, | - |
481 | m_progressMinimum, | - |
482 | m_progressMaximum)); | - |
483 | interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Progress, | - |
484 | m_progressValue, | - |
485 | m_progressText)); | - |
486 | } executed: } Execution Count:28 | 28 |
487 | | - |
488 | QtPrivate::ResultIteratorBase it = m_results.begin(); | - |
489 | while (it != m_results.end()) { evaluated: it != m_results.end() yes Evaluation Count:9 | yes Evaluation Count:28 |
| 9-28 |
490 | const int begin = it.resultIndex(); | - |
491 | const int end = begin + it.batchSize(); | - |
492 | interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::ResultsReady, | - |
493 | begin, | - |
494 | end)); | - |
495 | it.batchedAdvance(); | - |
496 | } executed: } Execution Count:9 | 9 |
497 | | - |
498 | if (state & QFutureInterfaceBase::Paused) partially evaluated: state & QFutureInterfaceBase::Paused no Evaluation Count:0 | yes Evaluation Count:28 |
| 0-28 |
499 | interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Paused)); never executed: interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Paused)); | 0 |
500 | | - |
501 | if (state & QFutureInterfaceBase::Canceled) evaluated: state & QFutureInterfaceBase::Canceled yes Evaluation Count:5 | yes Evaluation Count:23 |
| 5-23 |
502 | interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Canceled)); executed: interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Canceled)); Execution Count:5 | 5 |
503 | | - |
504 | if (state & QFutureInterfaceBase::Finished) evaluated: state & QFutureInterfaceBase::Finished yes Evaluation Count:14 | yes Evaluation Count:14 |
| 14 |
505 | interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Finished)); executed: interface->postCallOutEvent(QFutureCallOutEvent(QFutureCallOutEvent::Finished)); Execution Count:14 | 14 |
506 | | - |
507 | outputConnections.append(interface); | - |
508 | } executed: } Execution Count:28 | 28 |
509 | | - |
510 | void QFutureInterfaceBasePrivate::disconnectOutputInterface(QFutureCallOutInterface *interface) | - |
511 | { | - |
512 | QMutexLocker lock(&m_mutex); | - |
513 | const int index = outputConnections.indexOf(interface); | - |
514 | if (index == -1) evaluated: index == -1 yes Evaluation Count:22 | yes Evaluation Count:28 |
| 22-28 |
515 | return; executed: return; Execution Count:22 | 22 |
516 | outputConnections.removeAt(index); | - |
517 | | - |
518 | interface->callOutInterfaceDisconnected(); | - |
519 | } executed: } Execution Count:28 | 28 |
520 | | - |
521 | void QFutureInterfaceBasePrivate::setState(QFutureInterfaceBase::State newState) | - |
522 | { | - |
523 | state = newState; | - |
524 | } executed: } Execution Count:582985 | 582985 |
525 | | - |
526 | | - |
527 | | - |
| | |