qsemaphore.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/thread/qsemaphore.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5class QSemaphorePrivate {-
6public:-
7 inline QSemaphorePrivate(int n) : avail(n) { }
executed 1373213 times by 333 tests: end of block
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • ...
1373213
8-
9 QMutex mutex;-
10 QWaitCondition cond;-
11-
12 int avail;-
13};-
14-
15-
16-
17-
18-
19-
20-
21QSemaphore::QSemaphore(int n)-
22{-
23 ((!(n >= 0)) ? qt_assert_x("QSemaphore", "parameter 'n' must be non-negative",__FILE__,118) : qt_noop());-
24 d = new QSemaphorePrivate(n);-
25}
executed 1373213 times by 333 tests: end of block
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • ...
1373213
26-
27-
28-
29-
30-
31-
32-
33QSemaphore::~QSemaphore()-
34{ delete d; }
executed 1373225 times by 342 tests: end of block
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • ...
1373225
35void QSemaphore::acquire(int n)-
36{-
37 ((!(n >= 0)) ? qt_assert_x("QSemaphore::acquire", "parameter 'n' must be non-negative",__FILE__,140) : qt_noop());-
38 QMutexLocker locker(&d->mutex);-
39 while (n > d->avail
n > d->availDescription
TRUEevaluated 553926 times by 200 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • ...
FALSEevaluated 3425674 times by 333 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • ...
)
553926-3425674
40 d->cond.wait(locker.mutex());
executed 553926 times by 200 tests: d->cond.wait(locker.mutex());
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • ...
553926
41 d->avail -= n;-
42}
executed 3425674 times by 333 tests: end of block
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • ...
3425674
43void QSemaphore::release(int n)-
44{-
45 ((!(n >= 0)) ? qt_assert_x("QSemaphore::release", "parameter 'n' must be non-negative",__FILE__,159) : qt_noop());-
46 QMutexLocker locker(&d->mutex);-
47 d->avail += n;-
48 d->cond.wakeAll();-
49}
executed 5056536 times by 334 tests: end of block
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • ...
5056536
50-
51-
52-
53-
54-
55-
56-
57int QSemaphore::available() const-
58{-
59 QMutexLocker locker(&d->mutex);-
60 return
executed 82 times by 2 tests: return d->avail;
Executed by:
  • tst_QDBusThreading
  • tst_QSemaphore
d->avail;
executed 82 times by 2 tests: return d->avail;
Executed by:
  • tst_QDBusThreading
  • tst_QSemaphore
82
61}-
62bool QSemaphore::tryAcquire(int n)-
63{-
64 ((!(n >= 0)) ? qt_assert_x("QSemaphore::tryAcquire", "parameter 'n' must be non-negative",__FILE__,190) : qt_noop());-
65 QMutexLocker locker(&d->mutex);-
66 if (n > d->avail
n > d->availDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QSemaphore
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QSemaphore
)
4-8
67 return
executed 8 times by 1 test: return false;
Executed by:
  • tst_QSemaphore
false;
executed 8 times by 1 test: return false;
Executed by:
  • tst_QSemaphore
8
68 d->avail -= n;-
69 return
executed 4 times by 1 test: return true;
Executed by:
  • tst_QSemaphore
true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_QSemaphore
4
70}-
71bool QSemaphore::tryAcquire(int n, int timeout)-
72{-
73 ((!(n >= 0)) ? qt_assert_x("QSemaphore::tryAcquire", "parameter 'n' must be non-negative",__FILE__,216) : qt_noop());-
74 QMutexLocker locker(&d->mutex);-
75 if (timeout < 0
timeout < 0Description
TRUEnever evaluated
FALSEevaluated 1630882 times by 4 tests
Evaluated by:
  • tst_QReadWriteLock
  • tst_QSemaphore
  • tst_QSslSocket
  • tst_QThreadPool
) {
0-1630882
76 while (n > d->avail
n > d->availDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
77 d->cond.wait(locker.mutex());
never executed: d->cond.wait(locker.mutex());
0
78 }
never executed: end of block
else {
0
79 QElapsedTimer timer;-
80 timer.start();-
81 while (n > d->avail
n > d->availDescription
TRUEevaluated 194055 times by 4 tests
Evaluated by:
  • tst_QReadWriteLock
  • tst_QSemaphore
  • tst_QSslSocket
  • tst_QThreadPool
FALSEevaluated 1630859 times by 3 tests
Evaluated by:
  • tst_QSemaphore
  • tst_QSslSocket
  • tst_QThreadPool
) {
194055-1630859
82 const qint64 elapsed = timer.elapsed();-
83 if (timeout - elapsed <= 0
timeout - elapsed <= 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QSemaphore
FALSEevaluated 194054 times by 4 tests
Evaluated by:
  • tst_QReadWriteLock
  • tst_QSemaphore
  • tst_QSslSocket
  • tst_QThreadPool
1-194054
84 || !d->cond.wait(locker.mutex(), timeout - elapsed)
!d->cond.wait(...out - elapsed)Description
TRUEevaluated 22 times by 3 tests
Evaluated by:
  • tst_QReadWriteLock
  • tst_QSemaphore
  • tst_QThreadPool
FALSEevaluated 194032 times by 3 tests
Evaluated by:
  • tst_QSemaphore
  • tst_QSslSocket
  • tst_QThreadPool
)
22-194032
85 return
executed 23 times by 3 tests: return false;
Executed by:
  • tst_QReadWriteLock
  • tst_QSemaphore
  • tst_QThreadPool
false;
executed 23 times by 3 tests: return false;
Executed by:
  • tst_QReadWriteLock
  • tst_QSemaphore
  • tst_QThreadPool
23
86 }
executed 194032 times by 3 tests: end of block
Executed by:
  • tst_QSemaphore
  • tst_QSslSocket
  • tst_QThreadPool
194032
87 }
executed 1630859 times by 3 tests: end of block
Executed by:
  • tst_QSemaphore
  • tst_QSslSocket
  • tst_QThreadPool
1630859
88 d->avail -= n;-
89 return
executed 1630859 times by 3 tests: return true;
Executed by:
  • tst_QSemaphore
  • tst_QSslSocket
  • tst_QThreadPool
true;
executed 1630859 times by 3 tests: return true;
Executed by:
  • tst_QSemaphore
  • tst_QSslSocket
  • tst_QThreadPool
1630859
90-
91-
92}-
93-
94-
Switch to Source codePreprocessed file

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