Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | static inline bool isRecursive(QMutexData *d) | - |
11 | { | - |
12 | register quintptr u = quintptr(d); | - |
13 | if (__builtin_expect(!!(u <= 0x3), true)) evaluated: __builtin_expect(!!(u <= 0x3), true) yes Evaluation Count:28807206 | yes Evaluation Count:2150349 |
| 2150349-28807206 |
14 | return false; executed: return false; Execution Count:28817391 | 28817391 |
15 | | - |
16 | qt_noop(); | - |
17 | return true; executed: return true; Execution Count:2150356 | 2150356 |
18 | | - |
19 | | - |
20 | | - |
21 | } | - |
22 | | - |
23 | class QRecursiveMutexPrivate : public QMutexData | - |
24 | { | - |
25 | public: | - |
26 | QRecursiveMutexPrivate() | - |
27 | : QMutexData(QMutex::Recursive), owner(0), count(0) {} executed: } Execution Count:2832 | 2832 |
28 | Qt::HANDLE owner; | - |
29 | uint count; | - |
30 | QMutex mutex; | - |
31 | | - |
32 | bool lock(int timeout) ; | - |
33 | void unlock() ; | - |
34 | }; | - |
35 | QMutex::QMutex(RecursionMode mode) | - |
36 | { | - |
37 | d_ptr.store(mode == Recursive ? new QRecursiveMutexPrivate : 0); | - |
38 | } executed: } Execution Count:6100234 | 6100234 |
39 | | - |
40 | | - |
41 | | - |
42 | | - |
43 | | - |
44 | | - |
45 | QMutex::~QMutex() | - |
46 | { | - |
47 | QMutexData *d = d_ptr.load(); | - |
48 | if (isRecursive()) { evaluated: isRecursive() yes Evaluation Count:3976 | yes Evaluation Count:6099918 |
| 3976-6099918 |
49 | delete static_cast<QRecursiveMutexPrivate *>(d); | - |
50 | } else if (d) { evaluated: d yes Evaluation Count:1 | yes Evaluation Count:6099293 |
executed: } Execution Count:3976 | 1-6099293 |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | QMessageLogger("thread/qmutex.cpp", 194, __PRETTY_FUNCTION__).warning("QMutex: destroying locked mutex"); | - |
59 | } executed: } Execution Count:1 | 1 |
60 | } | - |
61 | void QMutex::lock() | - |
62 | { | - |
63 | if (fastTryLock()) evaluated: fastTryLock() yes Evaluation Count:83041693 | yes Evaluation Count:5693977 |
| 5693977-83041693 |
64 | return; executed: return; Execution Count:83027132 | 83027132 |
65 | QMutexData *current = d_ptr.loadAcquire(); | - |
66 | if (::isRecursive(current)) evaluated: ::isRecursive(current) yes Evaluation Count:1067383 | yes Evaluation Count:4623445 |
| 1067383-4623445 |
67 | static_cast<QRecursiveMutexPrivate *>(current)->lock(-1); executed: static_cast<QRecursiveMutexPrivate *>(current)->lock(-1); Execution Count:1067379 | 1067379 |
68 | else | - |
69 | lockInternal(); executed: lockInternal(); Execution Count:4621810 | 4621810 |
70 | } | - |
71 | bool QMutex::tryLock(int timeout) | - |
72 | { | - |
73 | if (fastTryLock()) evaluated: fastTryLock() yes Evaluation Count:5267752 | yes Evaluation Count:257876 |
| 257876-5267752 |
74 | return true; executed: return true; Execution Count:5267751 | 5267751 |
75 | QMutexData *current = d_ptr.loadAcquire(); | - |
76 | if (::isRecursive(current)) evaluated: ::isRecursive(current) yes Evaluation Count:10819 | yes Evaluation Count:243072 |
| 10819-243072 |
77 | return static_cast<QRecursiveMutexPrivate *>(current)->lock(timeout); executed: return static_cast<QRecursiveMutexPrivate *>(current)->lock(timeout); Execution Count:10819 | 10819 |
78 | else | - |
79 | return lockInternal(timeout); executed: return lockInternal(timeout); Execution Count:241421 | 241421 |
80 | } | - |
81 | void QMutex::unlock() | - |
82 | { | - |
83 | if (fastTryUnlock()) evaluated: fastTryUnlock() yes Evaluation Count:85094430 | yes Evaluation Count:8946247 |
| 8946247-85094430 |
84 | return; executed: return; Execution Count:85079807 | 85079807 |
85 | QMutexData *current = d_ptr.loadAcquire(); | - |
86 | if (::isRecursive(current)) evaluated: ::isRecursive(current) yes Evaluation Count:1068201 | yes Evaluation Count:7877992 |
| 1068201-7877992 |
87 | static_cast<QRecursiveMutexPrivate *>(current)->unlock(); executed: static_cast<QRecursiveMutexPrivate *>(current)->unlock(); Execution Count:1068201 | 1068201 |
88 | else | - |
89 | unlockInternal(); executed: unlockInternal(); Execution Count:7877982 | 7877982 |
90 | } | - |
91 | bool QBasicMutex::isRecursive() | - |
92 | { | - |
93 | return ::isRecursive(d_ptr.loadAcquire()); executed: return ::isRecursive(d_ptr.loadAcquire()); Execution Count:16169411 | 16169411 |
94 | } | - |
95 | inline bool QRecursiveMutexPrivate::lock(int timeout) | - |
96 | { | - |
97 | Qt::HANDLE self = QThread::currentThreadId(); | - |
98 | if (owner == self) { evaluated: owner == self yes Evaluation Count:2240 | yes Evaluation Count:1075954 |
| 2240-1075954 |
99 | ++count; | - |
100 | qt_noop(); | - |
101 | return true; executed: return true; Execution Count:2240 | 2240 |
102 | } | - |
103 | bool success = true; | - |
104 | if (timeout == -1) { evaluated: timeout == -1 yes Evaluation Count:1065742 | yes Evaluation Count:10216 |
| 10216-1065742 |
105 | mutex.QBasicMutex::lock(); | - |
106 | } else { executed: } Execution Count:1065759 | 1065759 |
107 | success = mutex.tryLock(timeout); | - |
108 | } executed: } Execution Count:10216 | 10216 |
109 | | - |
110 | if (success) evaluated: success yes Evaluation Count:1065966 | yes Evaluation Count:10008 |
| 10008-1065966 |
111 | owner = self; executed: owner = self; Execution Count:1065942 | 1065942 |
112 | return success; executed: return success; Execution Count:1075972 | 1075972 |
113 | } | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | inline void QRecursiveMutexPrivate::unlock() | - |
119 | { | - |
120 | if (count > 0) { evaluated: count > 0 yes Evaluation Count:2240 | yes Evaluation Count:1065953 |
| 2240-1065953 |
121 | count--; | - |
122 | } else { executed: } Execution Count:2240 | 2240 |
123 | owner = 0; | - |
124 | mutex.QBasicMutex::unlock(); | - |
125 | } executed: } Execution Count:1065967 | 1065967 |
126 | } | - |
127 | | - |
128 | | - |
129 | | - |
130 | | - |
131 | | - |
| | |