| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | class QSemaphorePrivate { | - |
| 6 | public: | - |
| 7 | inline QSemaphorePrivate(int n) : avail(n) { } executed: }Execution Count:2159692 | 2159692 |
| 8 | | - |
| 9 | QMutex mutex; | - |
| 10 | QWaitCondition cond; | - |
| 11 | | - |
| 12 | int avail; | - |
| 13 | }; | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | QSemaphore::QSemaphore(int n) | - |
| 22 | { | - |
| 23 | qt_noop(); | - |
| 24 | d = new QSemaphorePrivate(n); | - |
| 25 | } executed: }Execution Count:2159692 | 2159692 |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | QSemaphore::~QSemaphore() | - |
| 34 | { delete d; } executed: }Execution Count:2159676 | 2159676 |
| 35 | void QSemaphore::acquire(int n) | - |
| 36 | { | - |
| 37 | qt_noop(); | - |
| 38 | QMutexLocker locker(&d->mutex); | - |
| 39 | while (n > d->avail) evaluated: n > d->avail| yes Evaluation Count:2521799 | yes Evaluation Count:4203318 |
| 2521799-4203318 |
| 40 | d->cond.wait(locker.mutex()); executed: d->cond.wait(locker.mutex());Execution Count:2521799 | 2521799 |
| 41 | d->avail -= n; | - |
| 42 | } executed: }Execution Count:4201913 | 4201913 |
| 43 | void QSemaphore::release(int n) | - |
| 44 | { | - |
| 45 | qt_noop(); | - |
| 46 | QMutexLocker locker(&d->mutex); | - |
| 47 | d->avail += n; | - |
| 48 | d->cond.wakeAll(); | - |
| 49 | } executed: }Execution Count:8154081 | 8154081 |
| 50 | | - |
| 51 | | - |
| 52 | | - |
| 53 | | - |
| 54 | | - |
| 55 | | - |
| 56 | | - |
| 57 | int QSemaphore::available() const | - |
| 58 | { | - |
| 59 | QMutexLocker locker(&d->mutex); | - |
| 60 | return d->avail; executed: return d->avail;Execution Count:82 | 82 |
| 61 | } | - |
| 62 | bool QSemaphore::tryAcquire(int n) | - |
| 63 | { | - |
| 64 | qt_noop(); | - |
| 65 | QMutexLocker locker(&d->mutex); | - |
| 66 | if (n > d->avail) evaluated: n > d->avail| yes Evaluation Count:8 | yes Evaluation Count:4 |
| 4-8 |
| 67 | return false; executed: return false;Execution Count:8 | 8 |
| 68 | d->avail -= n; | - |
| 69 | return true; executed: return true;Execution Count:4 | 4 |
| 70 | } | - |
| 71 | bool QSemaphore::tryAcquire(int n, int timeout) | - |
| 72 | { | - |
| 73 | qt_noop(); | - |
| 74 | QMutexLocker locker(&d->mutex); | - |
| 75 | if (timeout < 0) { partially evaluated: timeout < 0| no Evaluation Count:0 | yes Evaluation Count:3945047 |
| 0-3945047 |
| 76 | while (n > d->avail) never evaluated: n > d->avail | 0 |
| 77 | d->cond.wait(locker.mutex()); never executed: d->cond.wait(locker.mutex()); | 0 |
| 78 | } else { | 0 |
| 79 | QElapsedTimer timer; | - |
| 80 | timer.start(); | - |
| 81 | while (n > d->avail) { evaluated: n > d->avail| yes Evaluation Count:221643 | yes Evaluation Count:3945024 |
| 221643-3945024 |
| 82 | const qint64 elapsed = timer.elapsed(); | - |
| 83 | if (timeout - elapsed <= 0 evaluated: timeout - elapsed <= 0| yes Evaluation Count:1 | yes Evaluation Count:221642 |
| 1-221642 |
| 84 | || !d->cond.wait(locker.mutex(), timeout - elapsed)) evaluated: !d->cond.wait(locker.mutex(), timeout - elapsed)| yes Evaluation Count:22 | yes Evaluation Count:221620 |
| 22-221620 |
| 85 | return false; executed: return false;Execution Count:23 | 23 |
| 86 | } executed: }Execution Count:221620 | 221620 |
| 87 | } executed: }Execution Count:3945024 | 3945024 |
| 88 | d->avail -= n; | - |
| 89 | return true; executed: return true;Execution Count:3945024 | 3945024 |
| 90 | | - |
| 91 | | - |
| 92 | } | - |
| 93 | | - |
| 94 | | - |
| 95 | | - |
| | |