OpenCoverage

qreadwritelock.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/thread/qreadwritelock.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5namespace {-
6enum {-
7 StateMask = 0x3,-
8 StateLockedForRead = 0x1,-
9 StateLockedForWrite = 0x2,-
10};-
11const auto dummyLockedForRead = reinterpret_cast<QReadWriteLockPrivate *>(quintptr(StateLockedForRead));-
12const auto dummyLockedForWrite = reinterpret_cast<QReadWriteLockPrivate *>(quintptr(StateLockedForWrite));-
13inline bool isUncontendedLocked(const QReadWriteLockPrivate *d)-
14{ return
executed 317361 times by 523 tests: return quintptr(d) & StateMask;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_NoApplication
  • tst_QDBusConnection_SpyHook
  • tst_QDBusServiceWatcher
  • tst_QDBusThreading
  • tst_QDirIterator
  • tst_QFile
  • tst_QGlobalStatic
  • tst_QMetaType
  • tst_QReadLocker
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_QWriteLocker
  • tst_collections - unknown status
  • tst_compiler - unknown status
  • tst_gestures - unknown status
  • tst_lancelot - unknown status
  • tst_languagechange - unknown status
  • tst_largefile - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_q_func_info - unknown status
  • ...
quintptr(d) & StateMask;
executed 317361 times by 523 tests: return quintptr(d) & StateMask;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_NoApplication
  • tst_QDBusConnection_SpyHook
  • tst_QDBusServiceWatcher
  • tst_QDBusThreading
  • tst_QDirIterator
  • tst_QFile
  • tst_QGlobalStatic
  • tst_QMetaType
  • tst_QReadLocker
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_QWriteLocker
  • tst_collections - unknown status
  • tst_compiler - unknown status
  • tst_gestures - unknown status
  • tst_lancelot - unknown status
  • tst_languagechange - unknown status
  • tst_largefile - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_q_func_info - unknown status
  • ...
}
317361
15}-
16QReadWriteLock::QReadWriteLock(RecursionMode recursionMode)-
17 : d_ptr(recursionMode == Recursive ? new QReadWriteLockPrivate(true) : nullptr)-
18{-
19 ((!(!(quintptr(d_ptr.load()) & StateMask))) ? qt_assert_x("QReadWriteLock::QReadWriteLock", "bad d_ptr alignment",__FILE__,147) : qt_noop());-
20}
executed 42232 times by 296 tests: end of block
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QAsn1Element
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • ...
42232
21-
22-
23-
24-
25-
26-
27-
28QReadWriteLock::~QReadWriteLock()-
29{-
30 auto d = d_ptr.load();-
31 if (isUncontendedLocked(d)
isUncontendedLocked(d)Description
TRUEnever evaluated
FALSEevaluated 43112 times by 519 tests
Evaluated by:
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_NoApplication
  • tst_QDBusConnection_SpyHook
  • tst_QDBusServiceWatcher
  • tst_QDBusThreading
  • tst_QGlobalStatic
  • tst_QReadLocker
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_QWriteLocker
  • tst_collections - unknown status
  • tst_compiler - unknown status
  • tst_gestures - unknown status
  • tst_lancelot - unknown status
  • tst_languagechange - unknown status
  • tst_largefile - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_q_func_info - unknown status
  • tst_qabstractanimation - unknown status
  • tst_qabstractbutton - unknown status
  • tst_qabstractfileengine - unknown status
  • tst_qabstractitemmodel - unknown status
  • ...
) {
0-43112
32 QMessageLogger(__FILE__, 160, __PRETTY_FUNCTION__).warning("QReadWriteLock: destroying locked QReadWriteLock");-
33 return;
never executed: return;
0
34 }-
35 delete d;-
36}
executed 43112 times by 519 tests: end of block
Executed by:
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_NoApplication
  • tst_QDBusConnection_SpyHook
  • tst_QDBusServiceWatcher
  • tst_QDBusThreading
  • tst_QGlobalStatic
  • tst_QReadLocker
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_QWriteLocker
  • tst_collections - unknown status
  • tst_compiler - unknown status
  • tst_gestures - unknown status
  • tst_lancelot - unknown status
  • tst_languagechange - unknown status
  • tst_largefile - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_platformsocketengine - unknown status
  • tst_q_func_info - unknown status
  • tst_qabstractanimation - unknown status
  • tst_qabstractbutton - unknown status
  • tst_qabstractfileengine - unknown status
  • tst_qabstractitemmodel - unknown status
  • ...
43112
37void QReadWriteLock::lockForRead()-
38{-
39 if (d_ptr.testAndSetAcquire(nullptr, dummyLockedForRead)
d_ptr.testAndS...LockedForRead)Description
TRUEevaluated 1557572 times by 355 tests
Evaluated by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QAsn1Element
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • ...
FALSEevaluated 143670 times by 10 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_Spdy
)
143670-1557572
40 return;
executed 1557572 times by 355 tests: return;
Executed by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QAsn1Element
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • ...
1557572
41 tryLockForRead(-1);-
42}
executed 143670 times by 10 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_Spdy
143670
43bool QReadWriteLock::tryLockForRead()-
44{-
45 return
executed 43 times by 2 tests: return tryLockForRead(0);
Executed by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
tryLockForRead(0);
executed 43 times by 2 tests: return tryLockForRead(0);
Executed by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
43
46}-
47bool QReadWriteLock::tryLockForRead(int timeout)-
48{-
49-
50 QReadWriteLockPrivate *d;-
51 if (d_ptr.testAndSetAcquire(nullptr, dummyLockedForRead, d)
d_ptr.testAndS...kedForRead, d)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QReadWriteLock
FALSEevaluated 143712 times by 10 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_Spdy
)
4-143712
52 return
executed 4 times by 1 test: return true;
Executed by:
  • tst_QReadWriteLock
true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_QReadWriteLock
4
53-
54 while (true) {-
55 if (d == 0
d == 0Description
TRUEnever evaluated
FALSEevaluated 143712 times by 10 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_Spdy
) {
0-143712
56 if (!d_ptr.testAndSetAcquire(nullptr, dummyLockedForRead, d)
!d_ptr.testAnd...kedForRead, d)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
57 continue;
never executed: continue;
0
58 return
never executed: return true;
true;
never executed: return true;
0
59 }-
60-
61 if ((
(quintptr(d) &...eLockedForReadDescription
TRUEevaluated 11198 times by 6 tests
Evaluated by:
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_Spdy
FALSEevaluated 132514 times by 6 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
quintptr(d) & StateMask) == StateLockedForRead
(quintptr(d) &...eLockedForReadDescription
TRUEevaluated 11198 times by 6 tests
Evaluated by:
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_Spdy
FALSEevaluated 132514 times by 6 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
11198-132514
62-
63 const auto val = reinterpret_cast<QReadWriteLockPrivate *>(quintptr(d) + (1U<<4));-
64 ((!(quintptr(val) > (1U<<4))) ? qt_assert_x("QReadWriteLock::tryLockForRead()", "Overflow in lock counter",-
65 __FILE__-
66 ,-
67 240-
68 ) : qt_noop())-
69 ;-
70 if (!d_ptr.testAndSetAcquire(d, val, d)
!d_ptr.testAnd...ire(d, val, d)Description
TRUEnever evaluated
FALSEevaluated 11198 times by 6 tests
Evaluated by:
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_Spdy
)
0-11198
71 continue;
never executed: continue;
0
72 return
executed 11198 times by 6 tests: return true;
Executed by:
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_Spdy
true;
executed 11198 times by 6 tests: return true;
Executed by:
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_Spdy
11198
73 }-
74-
75 if (d == dummyLockedForWrite
d == dummyLockedForWriteDescription
TRUEevaluated 42 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 132472 times by 6 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
42-132472
76 if (!timeout
!timeoutDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QReadWriteLock
FALSEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
)
2-40
77 return
executed 2 times by 1 test: return false;
Executed by:
  • tst_QReadWriteLock
false;
executed 2 times by 1 test: return false;
Executed by:
  • tst_QReadWriteLock
2
78-
79-
80 auto val = QReadWriteLockPrivate::allocate();-
81 val->writerCount = 1;-
82 if (!d_ptr.testAndSetOrdered(d, val, d)
!d_ptr.testAnd...red(d, val, d)Description
TRUEnever evaluated
FALSEevaluated 40 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
0-40
83 val->writerCount = 0;-
84 val->release();-
85 continue;
never executed: continue;
0
86 }-
87 d = val;-
88 }
executed 40 times by 3 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
40
89 ((!(!isUncontendedLocked(d))) ? qt_assert("!isUncontendedLocked(d)",__FILE__,260) : qt_noop());-
90-
91-
92 if (d->recursive
d->recursiveDescription
TRUEevaluated 126 times by 5 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 132386 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
)
126-132386
93 return
executed 126 times by 5 tests: return d->recursiveLockForRead(timeout);
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
d->recursiveLockForRead(timeout);
executed 126 times by 5 tests: return d->recursiveLockForRead(timeout);
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
126
94-
95 QMutexLocker lock(&d->mutex);-
96 if (d != d_ptr.load()
d != d_ptr.load()Description
TRUEnever evaluated
FALSEevaluated 132386 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
0-132386
97-
98-
99-
100-
101-
102-
103 d = d_ptr.loadAcquire();-
104 continue;
never executed: continue;
0
105 }-
106 return
executed 132386 times by 3 tests: return d->lockForRead(timeout);
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
d->lockForRead(timeout);
executed 132386 times by 3 tests: return d->lockForRead(timeout);
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
132386
107 }-
108}
never executed: end of block
0
109void QReadWriteLock::lockForWrite()-
110{-
111 tryLockForWrite(-1);-
112}
executed 348346 times by 568 tests: end of block
Executed by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QAsn1Element
  • tst_QBackingStore
  • ...
348346
113bool QReadWriteLock::tryLockForWrite()-
114{-
115 return
executed 62 times by 4 tests: return tryLockForWrite(0);
Executed by:
  • tst_QReadLocker
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_QWriteLocker
tryLockForWrite(0);
executed 62 times by 4 tests: return tryLockForWrite(0);
Executed by:
  • tst_QReadLocker
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_QWriteLocker
62
116}-
117bool QReadWriteLock::tryLockForWrite(int timeout)-
118{-
119-
120 QReadWriteLockPrivate *d;-
121 if (d_ptr.testAndSetAcquire(nullptr, dummyLockedForWrite, d)
d_ptr.testAndS...edForWrite, d)Description
TRUEevaluated 345353 times by 565 tests
Evaluated by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QAsn1Element
  • tst_QBackingStore
  • tst_QBoxLayout
  • ...
FALSEevaluated 3057 times by 11 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadLocker
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_QWriteLocker
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
)
3057-345353
122 return
executed 345353 times by 565 tests: return true;
Executed by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QAsn1Element
  • tst_QBackingStore
  • tst_QBoxLayout
  • ...
true;
executed 345353 times by 565 tests: return true;
Executed by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QAsn1Element
  • tst_QBackingStore
  • tst_QBoxLayout
  • ...
345353
123-
124 while (true) {-
125 if (d == 0
d == 0Description
TRUEnever evaluated
FALSEevaluated 3057 times by 11 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadLocker
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_QWriteLocker
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
) {
0-3057
126 if (!d_ptr.testAndSetAcquire(d, dummyLockedForWrite, d)
!d_ptr.testAnd...edForWrite, d)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
127 continue;
never executed: continue;
0
128 return
never executed: return true;
true;
never executed: return true;
0
129 }-
130-
131 if (isUncontendedLocked(d)
isUncontendedLocked(d)Description
TRUEevaluated 88 times by 5 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadLocker
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_QWriteLocker
FALSEevaluated 2969 times by 9 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
) {
88-2969
132 if (!timeout
!timeoutDescription
TRUEevaluated 10 times by 3 tests
Evaluated by:
  • tst_QReadLocker
  • tst_QReadWriteLock
  • tst_QWriteLocker
FALSEevaluated 78 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
)
10-78
133 return
executed 10 times by 3 tests: return false;
Executed by:
  • tst_QReadLocker
  • tst_QReadWriteLock
  • tst_QWriteLocker
false;
executed 10 times by 3 tests: return false;
Executed by:
  • tst_QReadLocker
  • tst_QReadWriteLock
  • tst_QWriteLocker
10
134-
135-
136 auto val = QReadWriteLockPrivate::allocate();-
137 if (d == dummyLockedForWrite
d == dummyLockedForWriteDescription
TRUEevaluated 54 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 24 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
)
24-54
138 val->writerCount = 1;
executed 54 times by 3 tests: val->writerCount = 1;
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
54
139 else-
140 val->readerCount = (quintptr(d) >> 4) + 1;
executed 24 times by 3 tests: val->readerCount = (quintptr(d) >> 4) + 1;
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
24
141 if (!d_ptr.testAndSetOrdered(d, val, d)
!d_ptr.testAnd...red(d, val, d)Description
TRUEnever evaluated
FALSEevaluated 78 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
0-78
142 val->writerCount = val->readerCount = 0;-
143 val->release();-
144 continue;
never executed: continue;
0
145 }-
146 d = val;-
147 }
executed 78 times by 3 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
78
148 ((!(!isUncontendedLocked(d))) ? qt_assert("!isUncontendedLocked(d)",__FILE__,367) : qt_noop());-
149-
150-
151 if (d->recursive
d->recursiveDescription
TRUEevaluated 76 times by 8 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
FALSEevaluated 2971 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
)
76-2971
152 return
executed 76 times by 8 tests: return d->recursiveLockForWrite(timeout);
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
d->recursiveLockForWrite(timeout);
executed 76 times by 8 tests: return d->recursiveLockForWrite(timeout);
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
76
153-
154 QMutexLocker lock(&d->mutex);-
155 if (d != d_ptr.load()
d != d_ptr.load()Description
TRUEnever evaluated
FALSEevaluated 2971 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
0-2971
156-
157-
158-
159 d = d_ptr.loadAcquire();-
160 continue;
never executed: continue;
0
161 }-
162 return
executed 2971 times by 3 tests: return d->lockForWrite(timeout);
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
d->lockForWrite(timeout);
executed 2971 times by 3 tests: return d->lockForWrite(timeout);
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
2971
163 }-
164}
never executed: end of block
0
165void QReadWriteLock::unlock()-
166{-
167 QReadWriteLockPrivate *d = d_ptr.load();-
168 while (true) {-
169 ((!(d)) ? qt_assert_x("QReadWriteLock::unlock()", "Cannot unlock an unlocked lock",__FILE__,397) : qt_noop());-
170-
171-
172 if (quintptr(d) <= 2
quintptr(d) <= 2Description
TRUEevaluated 1902811 times by 572 tests
Evaluated by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QAsn1Element
  • tst_QBackingStore
  • ...
FALSEevaluated 146830 times by 13 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_Spdy
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
) {
146830-1902811
173 if (!d_ptr.testAndSetRelease(d, nullptr, d)
!d_ptr.testAnd...d, nullptr, d)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QReadWriteLock
FALSEevaluated 1902810 times by 572 tests
Evaluated by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QAsn1Element
  • tst_QBackingStore
  • ...
)
1-1902810
174 continue;
executed 1 time by 1 test: continue;
Executed by:
  • tst_QReadWriteLock
1
175 return;
executed 1902810 times by 572 tests: return;
Executed by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QArrayData
  • tst_QArrayData_StrictIterators
  • tst_QAsn1Element
  • tst_QBackingStore
  • ...
1902810
176 }-
177-
178 if ((
(quintptr(d) &...eLockedForReadDescription
TRUEevaluated 11197 times by 6 tests
Evaluated by:
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_Spdy
FALSEevaluated 135633 times by 9 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
quintptr(d) & StateMask) == StateLockedForRead
(quintptr(d) &...eLockedForReadDescription
TRUEevaluated 11197 times by 6 tests
Evaluated by:
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_Spdy
FALSEevaluated 135633 times by 9 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
) {
11197-135633
179 ((!(quintptr(d) > (1U<<4))) ? qt_assert("quintptr(d) > (1U<<4)",__FILE__,407) : qt_noop());-
180-
181 auto val = reinterpret_cast<QReadWriteLockPrivate *>(quintptr(d) - (1U<<4));-
182 if (!d_ptr.testAndSetRelease(d, val, d)
!d_ptr.testAnd...ase(d, val, d)Description
TRUEnever evaluated
FALSEevaluated 11197 times by 6 tests
Evaluated by:
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_Spdy
)
0-11197
183 continue;
never executed: continue;
0
184 return;
executed 11197 times by 6 tests: return;
Executed by:
  • tst_QGuiEventLoop
  • tst_QHostInfo
  • tst_QMetaType
  • tst_QNetworkReply
  • tst_QReadWriteLock
  • tst_Spdy
11197
185 }-
186-
187 ((!(!isUncontendedLocked(d))) ? qt_assert("!isUncontendedLocked(d)",__FILE__,415) : qt_noop());-
188-
189 if (d->recursive
d->recursiveDescription
TRUEevaluated 159 times by 8 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
FALSEevaluated 135474 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
159-135474
190 d->recursiveUnlock();-
191 return;
executed 159 times by 8 tests: return;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
159
192 }-
193-
194 QMutexLocker locker(&d->mutex);-
195 if (d->writerCount
d->writerCountDescription
TRUEevaluated 3064 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 132410 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
3064-132410
196 ((!(d->writerCount == 1)) ? qt_assert("d->writerCount == 1",__FILE__,424) : qt_noop());-
197 ((!(d->readerCount == 0)) ? qt_assert("d->readerCount == 0",__FILE__,425) : qt_noop());-
198 d->writerCount = 0;-
199 }
executed 3064 times by 3 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
else {
3064
200 ((!(d->readerCount > 0)) ? qt_assert("d->readerCount > 0",__FILE__,428) : qt_noop());-
201 d->readerCount--;-
202 if (d->readerCount > 0
d->readerCount > 0Description
TRUEevaluated 132145 times by 1 test
Evaluated by:
  • tst_QReadWriteLock
FALSEevaluated 265 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
)
265-132145
203 return;
executed 132145 times by 1 test: return;
Executed by:
  • tst_QReadWriteLock
132145
204 }
executed 265 times by 3 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
265
205-
206 if (d->waitingReaders
d->waitingReadersDescription
TRUEevaluated 327 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 3002 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
|| d->waitingWriters
d->waitingWritersDescription
TRUEevaluated 2884 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 118 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
118-3002
207 d->unlock();-
208 }
executed 3211 times by 3 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
else {
3211
209 ((!(d_ptr.load() == d)) ? qt_assert("d_ptr.load() == d",__FILE__,437) : qt_noop());-
210 d_ptr.storeRelease(nullptr);-
211 d->release();-
212 }
executed 118 times by 3 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
118
213 return;
executed 3329 times by 3 tests: return;
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
3329
214 }-
215}
never executed: end of block
0
216-
217-
218QReadWriteLock::StateForWaitCondition QReadWriteLock::stateForWaitCondition() const-
219{-
220 QReadWriteLockPrivate *d = d_ptr.load();-
221 switch (quintptr(d) & StateMask) {-
222 case
executed 25 times by 1 test: case StateLockedForRead:
Executed by:
  • tst_QWaitCondition
StateLockedForRead:
executed 25 times by 1 test: case StateLockedForRead:
Executed by:
  • tst_QWaitCondition
return
executed 25 times by 1 test: return LockedForRead;
Executed by:
  • tst_QWaitCondition
LockedForRead;
executed 25 times by 1 test: return LockedForRead;
Executed by:
  • tst_QWaitCondition
25
223 case
executed 108 times by 1 test: case StateLockedForWrite:
Executed by:
  • tst_QWaitCondition
StateLockedForWrite:
executed 108 times by 1 test: case StateLockedForWrite:
Executed by:
  • tst_QWaitCondition
return
executed 108 times by 1 test: return LockedForWrite;
Executed by:
  • tst_QWaitCondition
LockedForWrite;
executed 108 times by 1 test: return LockedForWrite;
Executed by:
  • tst_QWaitCondition
108
224 }-
225-
226 if (!d
!dDescription
TRUEnever evaluated
FALSEevaluated 141 times by 1 test
Evaluated by:
  • tst_QWaitCondition
)
0-141
227 return
never executed: return Unlocked;
Unlocked;
never executed: return Unlocked;
0
228 if (d->writerCount > 1
d->writerCount > 1Description
TRUEnever evaluated
FALSEevaluated 141 times by 1 test
Evaluated by:
  • tst_QWaitCondition
)
0-141
229 return
never executed: return RecursivelyLocked;
RecursivelyLocked;
never executed: return RecursivelyLocked;
0
230 else if (d->writerCount == 1
d->writerCount == 1Description
TRUEevaluated 123 times by 1 test
Evaluated by:
  • tst_QWaitCondition
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QWaitCondition
)
18-123
231 return
executed 123 times by 1 test: return LockedForWrite;
Executed by:
  • tst_QWaitCondition
LockedForWrite;
executed 123 times by 1 test: return LockedForWrite;
Executed by:
  • tst_QWaitCondition
123
232 return
executed 18 times by 1 test: return LockedForRead;
Executed by:
  • tst_QWaitCondition
LockedForRead;
executed 18 times by 1 test: return LockedForRead;
Executed by:
  • tst_QWaitCondition
18
233-
234}-
235-
236bool QReadWriteLockPrivate::lockForRead(int timeout)-
237{-
238 ((!(!mutex.tryLock())) ? qt_assert("!mutex.tryLock()",__FILE__,466) : qt_noop());-
239-
240 QElapsedTimer t;-
241 if (timeout > 0
timeout > 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QReadWriteLock
FALSEevaluated 132492 times by 6 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
)
1-132492
242 t.start();
executed 1 time by 1 test: t.start();
Executed by:
  • tst_QReadWriteLock
1
243-
244 while (waitingWriters
waitingWritersDescription
TRUEevaluated 386 times by 2 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
FALSEevaluated 132543 times by 6 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
|| writerCount
writerCountDescription
TRUEevaluated 72 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 132471 times by 6 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
72-132543
245 if (timeout == 0
timeout == 0Description
TRUEevaluated 21 times by 2 tests
Evaluated by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 437 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
)
21-437
246 return
executed 21 times by 2 tests: return false;
Executed by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
false;
executed 21 times by 2 tests: return false;
Executed by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
21
247 if (timeout > 0
timeout > 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QReadWriteLock
FALSEevaluated 429 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
8-429
248 auto elapsed = t.elapsed();-
249 if (elapsed > timeout
elapsed > timeoutDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QReadWriteLock
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QReadWriteLock
)
1-7
250 return
executed 1 time by 1 test: return false;
Executed by:
  • tst_QReadWriteLock
false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_QReadWriteLock
1
251 waitingReaders++;-
252 readerCond.wait(&mutex, timeout - elapsed);-
253 }
executed 7 times by 1 test: end of block
Executed by:
  • tst_QReadWriteLock
else {
7
254 waitingReaders++;-
255 readerCond.wait(&mutex);-
256 }
executed 429 times by 3 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
429
257 waitingReaders--;-
258 }
executed 436 times by 3 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
436
259 readerCount++;-
260 ((!(writerCount == 0)) ? qt_assert("writerCount == 0",__FILE__,488) : qt_noop());-
261 return
executed 132471 times by 6 tests: return true;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
true;
executed 132471 times by 6 tests: return true;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
132471
262}-
263-
264bool QReadWriteLockPrivate::lockForWrite(int timeout)-
265{-
266 ((!(!mutex.tryLock())) ? qt_assert("!mutex.tryLock()",__FILE__,494) : qt_noop());-
267-
268 QElapsedTimer t;-
269 if (timeout > 0
timeout > 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QReadWriteLock
FALSEevaluated 3034 times by 9 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
)
1-3034
270 t.start();
executed 1 time by 1 test: t.start();
Executed by:
  • tst_QReadWriteLock
1
271-
272 while (readerCount
readerCountDescription
TRUEevaluated 74 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 3276 times by 9 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
|| writerCount
writerCountDescription
TRUEevaluated 264 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 3012 times by 9 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
) {
74-3276
273 if (timeout == 0
timeout == 0Description
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 316 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
)
22-316
274 return
executed 22 times by 2 tests: return false;
Executed by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
false;
executed 22 times by 2 tests: return false;
Executed by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
22
275 if (timeout > 0
timeout > 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QReadWriteLock
FALSEevaluated 308 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
8-308
276 auto elapsed = t.elapsed();-
277 if (elapsed > timeout
elapsed > timeoutDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QReadWriteLock
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QReadWriteLock
) {
1-7
278 if (waitingReaders
waitingReadersDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QReadWriteLock
&& !waitingWriters
!waitingWritersDescription
TRUEnever evaluated
FALSEnever evaluated
&& !writerCount
!writerCountDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0-1
279-
280-
281 readerCond.wakeAll();-
282 }
never executed: end of block
0
283 return
executed 1 time by 1 test: return false;
Executed by:
  • tst_QReadWriteLock
false;
executed 1 time by 1 test: return false;
Executed by:
  • tst_QReadWriteLock
1
284 }-
285 waitingWriters++;-
286 writerCond.wait(&mutex, timeout - elapsed);-
287 }
executed 7 times by 1 test: end of block
Executed by:
  • tst_QReadWriteLock
else {
7
288 waitingWriters++;-
289 writerCond.wait(&mutex);-
290 }
executed 308 times by 3 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
308
291 waitingWriters--;-
292 }
executed 315 times by 3 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
315
293-
294 ((!(writerCount == 0)) ? qt_assert("writerCount == 0",__FILE__,522) : qt_noop());-
295 ((!(readerCount == 0)) ? qt_assert("readerCount == 0",__FILE__,523) : qt_noop());-
296 writerCount = 1;-
297 return
executed 3012 times by 9 tests: return true;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
true;
executed 3012 times by 9 tests: return true;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
3012
298}-
299-
300void QReadWriteLockPrivate::unlock()-
301{-
302 ((!(!mutex.tryLock())) ? qt_assert("!mutex.tryLock()",__FILE__,530) : qt_noop());-
303 if (waitingWriters
waitingWritersDescription
TRUEevaluated 2922 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 417 times by 9 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
)
417-2922
304 writerCond.wakeOne();
executed 2922 times by 3 tests: writerCond.wakeOne();
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
2922
305 else if (waitingReaders
waitingReadersDescription
TRUEevaluated 290 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 127 times by 8 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
)
127-290
306 readerCond.wakeAll();
executed 290 times by 3 tests: readerCond.wakeAll();
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
290
307}
executed 3339 times by 9 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
3339
308-
309bool QReadWriteLockPrivate::recursiveLockForRead(int timeout)-
310{-
311 ((!(recursive)) ? qt_assert("recursive",__FILE__,539) : qt_noop());-
312 QMutexLocker lock(&mutex);-
313-
314 Qt::HANDLE self = QThread::currentThreadId();-
315-
316 auto it = currentReaders.find(self);-
317 if (it != currentReaders.end()
it != currentReaders.end()Description
TRUEevaluated 19 times by 4 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 107 times by 5 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
19-107
318 ++it.value();-
319 return
executed 19 times by 4 tests: return true;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
true;
executed 19 times by 4 tests: return true;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
19
320 }-
321-
322 if (!lockForRead(timeout)
!lockForRead(timeout)Description
TRUEevaluated 21 times by 2 tests
Evaluated by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 86 times by 5 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
)
21-86
323 return
executed 21 times by 2 tests: return false;
Executed by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
false;
executed 21 times by 2 tests: return false;
Executed by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
21
324-
325 currentReaders.insert(self, 1);-
326 return
executed 86 times by 5 tests: return true;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
true;
executed 86 times by 5 tests: return true;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
86
327}-
328-
329bool QReadWriteLockPrivate::recursiveLockForWrite(int timeout)-
330{-
331 ((!(recursive)) ? qt_assert("recursive",__FILE__,559) : qt_noop());-
332 QMutexLocker lock(&mutex);-
333-
334 Qt::HANDLE self = QThread::currentThreadId();-
335 if (currentWriter == self
currentWriter == selfDescription
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 64 times by 8 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
) {
12-64
336 writerCount++;-
337 return
executed 12 times by 2 tests: return true;
Executed by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
true;
executed 12 times by 2 tests: return true;
Executed by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
12
338 }-
339-
340 if (!lockForWrite(timeout)
!lockForWrite(timeout)Description
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 42 times by 8 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
)
22-42
341 return
executed 22 times by 2 tests: return false;
Executed by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
false;
executed 22 times by 2 tests: return false;
Executed by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
22
342-
343 currentWriter = self;-
344 return
executed 42 times by 8 tests: return true;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
true;
executed 42 times by 8 tests: return true;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
42
345}-
346-
347void QReadWriteLockPrivate::recursiveUnlock()-
348{-
349 ((!(recursive)) ? qt_assert("recursive",__FILE__,577) : qt_noop());-
350 QMutexLocker lock(&mutex);-
351-
352 Qt::HANDLE self = QThread::currentThreadId();-
353 if (self == currentWriter
self == currentWriterDescription
TRUEevaluated 54 times by 8 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
FALSEevaluated 105 times by 5 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
54-105
354 if (--
--writerCount > 0Description
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 42 times by 8 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
writerCount > 0
--writerCount > 0Description
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 42 times by 8 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
)
12-42
355 return;
executed 12 times by 2 tests: return;
Executed by:
  • tst_QReadWriteLock
  • tst_QWaitCondition
12
356 currentWriter = 0;-
357 }
executed 42 times by 8 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
else {
42
358 auto it = currentReaders.find(self);-
359 if (it == currentReaders.end()
it == currentReaders.end()Description
TRUEnever evaluated
FALSEevaluated 105 times by 5 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
0-105
360 QMessageLogger(__FILE__, 588, __PRETTY_FUNCTION__).warning("QReadWriteLock::unlock: unlocking from a thread that did not lock");-
361 return;
never executed: return;
0
362 } else {-
363 if (--
--it.value() <= 0Description
TRUEevaluated 86 times by 5 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 19 times by 4 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
it.value() <= 0
--it.value() <= 0Description
TRUEevaluated 86 times by 5 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 19 times by 4 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
) {
19-86
364 currentReaders.erase(it);-
365 readerCount--;-
366 }
executed 86 times by 5 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
86
367 if (readerCount
readerCountDescription
TRUEevaluated 19 times by 4 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
FALSEevaluated 86 times by 5 tests
Evaluated by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
)
19-86
368 return;
executed 19 times by 4 tests: return;
Executed by:
  • tst_QAbstractFileEngine
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
19
369 }
executed 86 times by 5 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
86
370 }-
371-
372 unlock();-
373}
executed 128 times by 8 tests: end of block
Executed by:
  • tst_QAbstractFileEngine
  • tst_QDirIterator
  • tst_QFile
  • tst_QReadWriteLock
  • tst_QWaitCondition
  • tst_qabstractfileengine - unknown status
  • tst_qdiriterator - unknown status
  • tst_qfile - unknown status
128
374-
375-
376namespace {-
377struct FreeListConstants : QFreeListDefaultConstants {-
378 enum { BlockCount = 4, MaxIndex=0xffff };-
379 static const int Sizes[BlockCount];-
380};-
381const int FreeListConstants::Sizes[FreeListConstants::BlockCount] = {-
382 16,-
383 128,-
384 1024,-
385 FreeListConstants::MaxIndex - (16 + 128 + 1024)-
386};-
387-
388typedef QFreeList<QReadWriteLockPrivate, FreeListConstants> FreeList;-
389namespace { namespace Q_QGS_freelist { typedef FreeList Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
guard.load() =...c::InitializedDescription
TRUEevaluated 3 times by 3 tests
Evaluated by:
  • tst_qmetatype - unknown status
  • tst_qreadwritelock - unknown status
  • tst_qwaitcondition - unknown status
FALSEnever evaluated
) guard.store(QtGlobalStatic::Destroyed);
executed 3 times by 3 tests: guard.store(QtGlobalStatic::Destroyed);
Executed by:
  • tst_qmetatype - unknown status
  • tst_qreadwritelock - unknown status
  • tst_qwaitcondition - unknown status
}
executed 3 times by 3 tests: end of block
Executed by:
  • tst_qmetatype - unknown status
  • tst_qreadwritelock - unknown status
  • tst_qwaitcondition - unknown status
}; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return
executed 354 times by 3 tests: return &holder.value;
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
&holder.value;
executed 354 times by 3 tests: return &holder.value;
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
} } } static QGlobalStatic<FreeList, Q_QGS_freelist::innerFunction, Q_QGS_freelist::guard> freelist;;
0-354
390}-
391-
392QReadWriteLockPrivate *QReadWriteLockPrivate::allocate()-
393{-
394 int i = freelist->next();-
395 QReadWriteLockPrivate *d = &(*freelist)[i];-
396 d->id = i;-
397 ((!(!d->recursive)) ? qt_assert("!d->recursive",__FILE__,625) : qt_noop());-
398 ((!(!d->waitingReaders && !d->waitingReaders && !d->readerCount && !d->writerCount)) ? qt_assert("!d->waitingReaders && !d->waitingReaders && !d->readerCount && !d->writerCount",__FILE__,626) : qt_noop());-
399 return
executed 118 times by 3 tests: return d;
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
d;
executed 118 times by 3 tests: return d;
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
118
400}-
401-
402void QReadWriteLockPrivate::release()-
403{-
404 ((!(!recursive)) ? qt_assert("!recursive",__FILE__,632) : qt_noop());-
405 ((!(!waitingReaders && !waitingReaders && !readerCount && !writerCount)) ? qt_assert("!waitingReaders && !waitingReaders && !readerCount && !writerCount",__FILE__,633) : qt_noop());-
406 freelist->release(id);-
407}
executed 118 times by 3 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QReadWriteLock
  • tst_QWaitCondition
118
408-
Switch to Source codePreprocessed file

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