| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/thread/qfuturewatcher.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | - | |||||||
| 6 | - | |||||||
| 7 | QFutureWatcherBase::QFutureWatcherBase(QObject *parent) | - | ||||||
| 8 | :QObject(*new QFutureWatcherBasePrivate, parent) | - | ||||||
| 9 | { } executed 23 times by 1 test: end of blockExecuted by:
| 23 | ||||||
| 10 | void QFutureWatcherBase::cancel() | - | ||||||
| 11 | { | - | ||||||
| 12 | futureInterface().cancel(); | - | ||||||
| 13 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||
| 14 | void QFutureWatcherBase::setPaused(bool paused) | - | ||||||
| 15 | { | - | ||||||
| 16 | futureInterface().setPaused(paused); | - | ||||||
| 17 | } never executed: end of block | 0 | ||||||
| 18 | void QFutureWatcherBase::pause() | - | ||||||
| 19 | { | - | ||||||
| 20 | futureInterface().setPaused(true); | - | ||||||
| 21 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||
| 22 | void QFutureWatcherBase::resume() | - | ||||||
| 23 | { | - | ||||||
| 24 | futureInterface().setPaused(false); | - | ||||||
| 25 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||
| 26 | void QFutureWatcherBase::togglePaused() | - | ||||||
| 27 | { | - | ||||||
| 28 | futureInterface().togglePaused(); | - | ||||||
| 29 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||
| 30 | int QFutureWatcherBase::progressValue() const | - | ||||||
| 31 | { | - | ||||||
| 32 | return executed 6 times by 1 test: futureInterface().progressValue();return futureInterface().progressValue();Executed by:
executed 6 times by 1 test: return futureInterface().progressValue();Executed by:
| 6 | ||||||
| 33 | } | - | ||||||
| 34 | - | |||||||
| 35 | - | |||||||
| 36 | - | |||||||
| 37 | - | |||||||
| 38 | - | |||||||
| 39 | - | |||||||
| 40 | - | |||||||
| 41 | int QFutureWatcherBase::progressMinimum() const | - | ||||||
| 42 | { | - | ||||||
| 43 | return executed 6 times by 1 test: futureInterface().progressMinimum();return futureInterface().progressMinimum();Executed by:
executed 6 times by 1 test: return futureInterface().progressMinimum();Executed by:
| 6 | ||||||
| 44 | } | - | ||||||
| 45 | - | |||||||
| 46 | - | |||||||
| 47 | - | |||||||
| 48 | - | |||||||
| 49 | - | |||||||
| 50 | - | |||||||
| 51 | - | |||||||
| 52 | int QFutureWatcherBase::progressMaximum() const | - | ||||||
| 53 | { | - | ||||||
| 54 | return executed 6 times by 1 test: futureInterface().progressMaximum();return futureInterface().progressMaximum();Executed by:
executed 6 times by 1 test: return futureInterface().progressMaximum();Executed by:
| 6 | ||||||
| 55 | } | - | ||||||
| 56 | QString QFutureWatcherBase::progressText() const | - | ||||||
| 57 | { | - | ||||||
| 58 | return executed 6 times by 1 test: futureInterface().progressText();return futureInterface().progressText();Executed by:
executed 6 times by 1 test: return futureInterface().progressText();Executed by:
| 6 | ||||||
| 59 | } | - | ||||||
| 60 | - | |||||||
| 61 | - | |||||||
| 62 | - | |||||||
| 63 | - | |||||||
| 64 | - | |||||||
| 65 | - | |||||||
| 66 | bool QFutureWatcherBase::isStarted() const | - | ||||||
| 67 | { | - | ||||||
| 68 | return executed 7 times by 1 test: futureInterface().queryState(QFutureInterfaceBase::Started);return futureInterface().queryState(QFutureInterfaceBase::Started);Executed by:
executed 7 times by 1 test: return futureInterface().queryState(QFutureInterfaceBase::Started);Executed by:
| 7 | ||||||
| 69 | } | - | ||||||
| 70 | - | |||||||
| 71 | - | |||||||
| 72 | - | |||||||
| 73 | - | |||||||
| 74 | - | |||||||
| 75 | - | |||||||
| 76 | bool QFutureWatcherBase::isFinished() const | - | ||||||
| 77 | { | - | ||||||
| 78 | const QFutureWatcherBasePrivate * const d = d_func(); | - | ||||||
| 79 | return executed 11 times by 1 test: d->finished;return d->finished;Executed by:
executed 11 times by 1 test: return d->finished;Executed by:
| 11 | ||||||
| 80 | } | - | ||||||
| 81 | - | |||||||
| 82 | - | |||||||
| 83 | - | |||||||
| 84 | - | |||||||
| 85 | - | |||||||
| 86 | - | |||||||
| 87 | bool QFutureWatcherBase::isRunning() const | - | ||||||
| 88 | { | - | ||||||
| 89 | return executed 6 times by 1 test: futureInterface().queryState(QFutureInterfaceBase::Running);return futureInterface().queryState(QFutureInterfaceBase::Running);Executed by:
executed 6 times by 1 test: return futureInterface().queryState(QFutureInterfaceBase::Running);Executed by:
| 6 | ||||||
| 90 | } | - | ||||||
| 91 | bool QFutureWatcherBase::isCanceled() const | - | ||||||
| 92 | { | - | ||||||
| 93 | return executed 7 times by 1 test: futureInterface().queryState(QFutureInterfaceBase::Canceled);return futureInterface().queryState(QFutureInterfaceBase::Canceled);Executed by:
executed 7 times by 1 test: return futureInterface().queryState(QFutureInterfaceBase::Canceled);Executed by:
| 7 | ||||||
| 94 | } | - | ||||||
| 95 | bool QFutureWatcherBase::isPaused() const | - | ||||||
| 96 | { | - | ||||||
| 97 | return executed 6 times by 1 test: futureInterface().queryState(QFutureInterfaceBase::Paused);return futureInterface().queryState(QFutureInterfaceBase::Paused);Executed by:
executed 6 times by 1 test: return futureInterface().queryState(QFutureInterfaceBase::Paused);Executed by:
| 6 | ||||||
| 98 | } | - | ||||||
| 99 | - | |||||||
| 100 | - | |||||||
| 101 | - | |||||||
| 102 | - | |||||||
| 103 | - | |||||||
| 104 | - | |||||||
| 105 | void QFutureWatcherBase::waitForFinished() | - | ||||||
| 106 | { | - | ||||||
| 107 | futureInterface().waitForFinished(); | - | ||||||
| 108 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||
| 109 | - | |||||||
| 110 | bool QFutureWatcherBase::event(QEvent *event) | - | ||||||
| 111 | { | - | ||||||
| 112 | QFutureWatcherBasePrivate * const d = d_func(); | - | ||||||
| 113 | if (event->type() == QEvent::FutureCallOut
| 0-1288 | ||||||
| 114 | QFutureCallOutEvent *callOutEvent = static_cast<QFutureCallOutEvent *>(event); | - | ||||||
| 115 | - | |||||||
| 116 | if (futureInterface().isPaused()
| 7-1281 | ||||||
| 117 | d->pendingCallOutEvents.append(callOutEvent->clone()); | - | ||||||
| 118 | return executed 7 times by 1 test: true;return true;Executed by:
executed 7 times by 1 test: return true;Executed by:
| 7 | ||||||
| 119 | } | - | ||||||
| 120 | - | |||||||
| 121 | if (callOutEvent->callOutType == QFutureCallOutEvent::Resumed
| 1-1280 | ||||||
| 122 | && !d->pendingCallOutEvents.isEmpty()
| 0-1 | ||||||
| 123 | - | |||||||
| 124 | d->sendCallOutEvent(callOutEvent); | - | ||||||
| 125 | - | |||||||
| 126 | - | |||||||
| 127 | for (int i = 0; i < d->pendingCallOutEvents.count()
| 1-7 | ||||||
| 128 | d->sendCallOutEvent(d->pendingCallOutEvents.at(i)); executed 7 times by 1 test: d->sendCallOutEvent(d->pendingCallOutEvents.at(i));Executed by:
| 7 | ||||||
| 129 | qDeleteAll(d->pendingCallOutEvents); | - | ||||||
| 130 | d->pendingCallOutEvents.clear(); | - | ||||||
| 131 | } executed 1 time by 1 test: else {end of blockExecuted by:
| 1 | ||||||
| 132 | d->sendCallOutEvent(callOutEvent); | - | ||||||
| 133 | } executed 1280 times by 1 test: end of blockExecuted by:
| 1280 | ||||||
| 134 | return executed 1281 times by 1 test: true;return true;Executed by:
executed 1281 times by 1 test: return true;Executed by:
| 1281 | ||||||
| 135 | } | - | ||||||
| 136 | return never executed: QObject::event(event);return QObject::event(event);never executed: return QObject::event(event); | 0 | ||||||
| 137 | } | - | ||||||
| 138 | void QFutureWatcherBase::setPendingResultsLimit(int limit) | - | ||||||
| 139 | { | - | ||||||
| 140 | QFutureWatcherBasePrivate * const d = d_func(); | - | ||||||
| 141 | d->maximumPendingResultsReady = limit; | - | ||||||
| 142 | } never executed: end of block | 0 | ||||||
| 143 | - | |||||||
| 144 | void QFutureWatcherBase::connectNotify(const QMetaMethod &signal) | - | ||||||
| 145 | { | - | ||||||
| 146 | QFutureWatcherBasePrivate * const d = d_func(); | - | ||||||
| 147 | static const QMetaMethod resultReadyAtSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::resultReadyAt); | - | ||||||
| 148 | if (signal == resultReadyAtSignal
| 19-23 | ||||||
| 149 | d->resultAtConnected.ref(); executed 19 times by 1 test: d->resultAtConnected.ref();Executed by:
| 19 | ||||||
| 150 | - | |||||||
| 151 | static const QMetaMethod finishedSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::finished); | - | ||||||
| 152 | if (signal == finishedSignal
| 11-31 | ||||||
| 153 | if (futureInterface().isRunning()
| 1-10 | ||||||
| 154 | - | |||||||
| 155 | - | |||||||
| 156 | QMessageLogger(__FILE__, 368, __PRETTY_FUNCTION__).warning("QFutureWatcher::connect: connecting after calling setFuture() is likely to produce race"); | - | ||||||
| 157 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||
| 158 | } executed 11 times by 1 test: end of blockExecuted by:
| 11 | ||||||
| 159 | - | |||||||
| 160 | } executed 42 times by 1 test: end of blockExecuted by:
| 42 | ||||||
| 161 | - | |||||||
| 162 | void QFutureWatcherBase::disconnectNotify(const QMetaMethod &signal) | - | ||||||
| 163 | { | - | ||||||
| 164 | QFutureWatcherBasePrivate * const d = d_func(); | - | ||||||
| 165 | static const QMetaMethod resultReadyAtSignal = QMetaMethod::fromSignal(&QFutureWatcherBase::resultReadyAt); | - | ||||||
| 166 | if (signal == resultReadyAtSignal
| 15-16 | ||||||
| 167 | d->resultAtConnected.deref(); executed 16 times by 1 test: d->resultAtConnected.deref();Executed by:
| 16 | ||||||
| 168 | } executed 31 times by 1 test: end of blockExecuted by:
| 31 | ||||||
| 169 | - | |||||||
| 170 | - | |||||||
| 171 | - | |||||||
| 172 | - | |||||||
| 173 | QFutureWatcherBasePrivate::QFutureWatcherBasePrivate() | - | ||||||
| 174 | : maximumPendingResultsReady(QThread::idealThreadCount() * 2), | - | ||||||
| 175 | resultAtConnected(0), | - | ||||||
| 176 | finished(true) | - | ||||||
| 177 | { } executed 23 times by 1 test: end of blockExecuted by:
| 23 | ||||||
| 178 | - | |||||||
| 179 | - | |||||||
| 180 | - | |||||||
| 181 | - | |||||||
| 182 | void QFutureWatcherBase::connectOutputInterface() | - | ||||||
| 183 | { | - | ||||||
| 184 | futureInterface().d->connectOutputInterface(d_func()); | - | ||||||
| 185 | } executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||
| 186 | - | |||||||
| 187 | - | |||||||
| 188 | - | |||||||
| 189 | - | |||||||
| 190 | void QFutureWatcherBase::disconnectOutputInterface(bool pendingAssignment) | - | ||||||
| 191 | { | - | ||||||
| 192 | if (pendingAssignment
| 23-28 | ||||||
| 193 | QFutureWatcherBasePrivate * const d = d_func(); | - | ||||||
| 194 | d->pendingResultsReady.store(0); | - | ||||||
| 195 | qDeleteAll(d->pendingCallOutEvents); | - | ||||||
| 196 | d->pendingCallOutEvents.clear(); | - | ||||||
| 197 | d->finished = false; | - | ||||||
| 198 | } executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||
| 199 | - | |||||||
| 200 | futureInterface().d->disconnectOutputInterface(d_func()); | - | ||||||
| 201 | } executed 51 times by 1 test: end of blockExecuted by:
| 51 | ||||||
| 202 | - | |||||||
| 203 | void QFutureWatcherBasePrivate::postCallOutEvent(const QFutureCallOutEvent &callOutEvent) | - | ||||||
| 204 | { | - | ||||||
| 205 | QFutureWatcherBase * const q = q_func(); | - | ||||||
| 206 | - | |||||||
| 207 | if (callOutEvent.callOutType == QFutureCallOutEvent::ResultsReady
| 160-1185 | ||||||
| 208 | if (pendingResultsReady.fetchAndAddRelaxed(1) >= maximumPendingResultsReady
| 21-1164 | ||||||
| 209 | q->futureInterface().d->internal_setThrottled(true); executed 1164 times by 1 test: q->futureInterface().d->internal_setThrottled(true);Executed by:
| 1164 | ||||||
| 210 | } executed 1185 times by 1 test: end of blockExecuted by:
| 1185 | ||||||
| 211 | - | |||||||
| 212 | QCoreApplication::postEvent(q, callOutEvent.clone()); | - | ||||||
| 213 | } executed 1345 times by 1 test: end of blockExecuted by:
| 1345 | ||||||
| 214 | - | |||||||
| 215 | void QFutureWatcherBasePrivate::callOutInterfaceDisconnected() | - | ||||||
| 216 | { | - | ||||||
| 217 | QCoreApplication::removePostedEvents(q_func(), QEvent::FutureCallOut); | - | ||||||
| 218 | } executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||
| 219 | - | |||||||
| 220 | void QFutureWatcherBasePrivate::sendCallOutEvent(QFutureCallOutEvent *event) | - | ||||||
| 221 | { | - | ||||||
| 222 | QFutureWatcherBase * const q = q_func(); | - | ||||||
| 223 | - | |||||||
| 224 | switch (event->callOutType) { | - | ||||||
| 225 | case executed 20 times by 1 test: QFutureCallOutEvent::Started:case QFutureCallOutEvent::Started:Executed by:
executed 20 times by 1 test: case QFutureCallOutEvent::Started:Executed by:
| 20 | ||||||
| 226 | q->started(); | - | ||||||
| 227 | break; executed 20 times by 1 test: break;Executed by:
| 20 | ||||||
| 228 | case executed 17 times by 1 test: QFutureCallOutEvent::Finished:case QFutureCallOutEvent::Finished:Executed by:
executed 17 times by 1 test: case QFutureCallOutEvent::Finished:Executed by:
| 17 | ||||||
| 229 | finished = true; | - | ||||||
| 230 | q->finished(); | - | ||||||
| 231 | break; executed 17 times by 1 test: break;Executed by:
| 17 | ||||||
| 232 | case executed 5 times by 1 test: QFutureCallOutEvent::Canceled:case QFutureCallOutEvent::Canceled:Executed by:
executed 5 times by 1 test: case QFutureCallOutEvent::Canceled:Executed by:
| 5 | ||||||
| 233 | pendingResultsReady.store(0); | - | ||||||
| 234 | q->canceled(); | - | ||||||
| 235 | break; executed 5 times by 1 test: break;Executed by:
| 5 | ||||||
| 236 | case executed 1 time by 1 test: QFutureCallOutEvent::Paused:case QFutureCallOutEvent::Paused:Executed by:
executed 1 time by 1 test: case QFutureCallOutEvent::Paused:Executed by:
| 1 | ||||||
| 237 | if (q->futureInterface().isCanceled()
| 0-1 | ||||||
| 238 | break; never executed: break; | 0 | ||||||
| 239 | q->paused(); | - | ||||||
| 240 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 241 | case executed 1 time by 1 test: QFutureCallOutEvent::Resumed:case QFutureCallOutEvent::Resumed:Executed by:
executed 1 time by 1 test: case QFutureCallOutEvent::Resumed:Executed by:
| 1 | ||||||
| 242 | if (q->futureInterface().isCanceled()
| 0-1 | ||||||
| 243 | break; never executed: break; | 0 | ||||||
| 244 | q->resumed(); | - | ||||||
| 245 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 246 | case executed 1180 times by 1 test: QFutureCallOutEvent::ResultsReady:case QFutureCallOutEvent::ResultsReady:Executed by:
executed 1180 times by 1 test: {case QFutureCallOutEvent::ResultsReady:Executed by:
| 1180 | ||||||
| 247 | if (q->futureInterface().isCanceled()
| 1-1179 | ||||||
| 248 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||
| 249 | - | |||||||
| 250 | if (pendingResultsReady.fetchAndAddRelaxed(-1) <= maximumPendingResultsReady
| 15-1164 | ||||||
| 251 | q->futureInterface().setThrottled(false); executed 15 times by 1 test: q->futureInterface().setThrottled(false);Executed by:
| 15 | ||||||
| 252 | - | |||||||
| 253 | const int beginIndex = event->index1; | - | ||||||
| 254 | const int endIndex = event->index2; | - | ||||||
| 255 | - | |||||||
| 256 | q->resultsReadyAt(beginIndex, endIndex); | - | ||||||
| 257 | - | |||||||
| 258 | if (resultAtConnected.load() <= 0
| 178-1001 | ||||||
| 259 | break; executed 1001 times by 1 test: break;Executed by:
| 1001 | ||||||
| 260 | - | |||||||
| 261 | for (int i = beginIndex; i < endIndex
| 178-15008 | ||||||
| 262 | q->resultReadyAt(i); executed 15008 times by 1 test: q->resultReadyAt(i);Executed by:
| 15008 | ||||||
| 263 | - | |||||||
| 264 | } break; executed 178 times by 1 test: break;Executed by:
| 178 | ||||||
| 265 | case executed 44 times by 1 test: QFutureCallOutEvent::Progress:case QFutureCallOutEvent::Progress:Executed by:
executed 44 times by 1 test: case QFutureCallOutEvent::Progress:Executed by:
| 44 | ||||||
| 266 | if (q->futureInterface().isCanceled()
| 5-39 | ||||||
| 267 | break; executed 5 times by 1 test: break;Executed by:
| 5 | ||||||
| 268 | - | |||||||
| 269 | q->progressValueChanged(event->index1); | - | ||||||
| 270 | if (!event->text.isNull()
| 4-35 | ||||||
| 271 | q->progressTextChanged(event->text); executed 4 times by 1 test: q->progressTextChanged(event->text);Executed by:
| 4 | ||||||
| 272 | break; executed 39 times by 1 test: break;Executed by:
| 39 | ||||||
| 273 | case executed 20 times by 1 test: QFutureCallOutEvent::ProgressRange:case QFutureCallOutEvent::ProgressRange:Executed by:
executed 20 times by 1 test: case QFutureCallOutEvent::ProgressRange:Executed by:
| 20 | ||||||
| 274 | q->progressRangeChanged(event->index1, event->index2); | - | ||||||
| 275 | break; executed 20 times by 1 test: break;Executed by:
| 20 | ||||||
| 276 | default never executed: :default:never executed: break;default:never executed: break; | 0 | ||||||
| 277 | } | - | ||||||
| 278 | } | - | ||||||
| 279 | - | |||||||
| Switch to Source code | Preprocessed file |