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:28902366 | yes Evaluation Count:1740741 |
| 1740741-28902366 |
14 | return false; executed: return false; Execution Count:28915692 | 28915692 |
15 | | - |
16 | qt_noop(); | - |
17 | return true; executed: return true; Execution Count:1740753 | 1740753 |
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:2797 | 2797 |
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:6178871 | 6178871 |
39 | | - |
40 | | - |
41 | | - |
42 | | - |
43 | | - |
44 | | - |
45 | QMutex::~QMutex() | - |
46 | { | - |
47 | QMutexData *d = d_ptr.load(); | - |
48 | if (isRecursive()) { evaluated: isRecursive() yes Evaluation Count:3896 | yes Evaluation Count:6178220 |
| 3896-6178220 |
49 | delete static_cast<QRecursiveMutexPrivate *>(d); | - |
50 | } else if (d) { evaluated: d yes Evaluation Count:1 | yes Evaluation Count:6177371 |
executed: } Execution Count:3896 | 1-6177371 |
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:70997742 | yes Evaluation Count:5482796 |
| 5482796-70997742 |
64 | return; executed: return; Execution Count:70983438 | 70983438 |
65 | QMutexData *current = d_ptr.loadAcquire(); | - |
66 | if (::isRecursive(current)) evaluated: ::isRecursive(current) yes Evaluation Count:862622 | yes Evaluation Count:4616721 |
| 862622-4616721 |
67 | static_cast<QRecursiveMutexPrivate *>(current)->lock(-1); executed: static_cast<QRecursiveMutexPrivate *>(current)->lock(-1); Execution Count:862621 | 862621 |
68 | else | - |
69 | lockInternal(); executed: lockInternal(); Execution Count:4615125 | 4615125 |
70 | } | - |
71 | bool QMutex::tryLock(int timeout) | - |
72 | { | - |
73 | if (fastTryLock()) evaluated: fastTryLock() yes Evaluation Count:5345185 | yes Evaluation Count:240004 |
| 240004-5345185 |
74 | return true; executed: return true; Execution Count:5345168 | 5345168 |
75 | QMutexData *current = d_ptr.loadAcquire(); | - |
76 | if (::isRecursive(current)) evaluated: ::isRecursive(current) yes Evaluation Count:10819 | yes Evaluation Count:226109 |
| 10819-226109 |
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:225214 | 225214 |
80 | } | - |
81 | void QMutex::unlock() | - |
82 | { | - |
83 | if (fastTryUnlock()) evaluated: fastTryUnlock() yes Evaluation Count:73149687 | yes Evaluation Count:8716875 |
| 8716875-73149687 |
84 | return; executed: return; Execution Count:73135986 | 73135986 |
85 | QMutexData *current = d_ptr.loadAcquire(); | - |
86 | if (::isRecursive(current)) evaluated: ::isRecursive(current) yes Evaluation Count:863447 | yes Evaluation Count:7853382 |
| 863447-7853382 |
87 | static_cast<QRecursiveMutexPrivate *>(current)->unlock(); executed: static_cast<QRecursiveMutexPrivate *>(current)->unlock(); Execution Count:863447 | 863447 |
88 | else | - |
89 | unlockInternal(); executed: unlockInternal(); Execution Count:7853368 | 7853368 |
90 | } | - |
91 | bool QBasicMutex::isRecursive() | - |
92 | { | - |
93 | return ::isRecursive(d_ptr.loadAcquire()); executed: return ::isRecursive(d_ptr.loadAcquire()); Execution Count:16323666 | 16323666 |
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:2184 | yes Evaluation Count:871256 |
| 2184-871256 |
99 | ++count; | - |
100 | qt_noop(); | - |
101 | return true; executed: return true; Execution Count:2184 | 2184 |
102 | } | - |
103 | bool success = true; | - |
104 | if (timeout == -1) { evaluated: timeout == -1 yes Evaluation Count:861042 | yes Evaluation Count:10216 |
| 10216-861042 |
105 | mutex.QBasicMutex::lock(); | - |
106 | } else { executed: } Execution Count:861049 | 861049 |
107 | success = mutex.tryLock(timeout); | - |
108 | } executed: } Execution Count:10216 | 10216 |
109 | | - |
110 | if (success) evaluated: success yes Evaluation Count:861253 | yes Evaluation Count:10008 |
| 10008-861253 |
111 | owner = self; executed: owner = self; Execution Count:861247 | 861247 |
112 | return success; executed: return success; Execution Count:871254 | 871254 |
113 | } | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | inline void QRecursiveMutexPrivate::unlock() | - |
119 | { | - |
120 | if (count > 0) { evaluated: count > 0 yes Evaluation Count:2184 | yes Evaluation Count:861254 |
| 2184-861254 |
121 | count--; | - |
122 | } else { executed: } Execution Count:2184 | 2184 |
123 | owner = 0; | - |
124 | mutex.QBasicMutex::unlock(); | - |
125 | } executed: } Execution Count:861256 | 861256 |
126 | } | - |
127 | | - |
128 | | - |
129 | | - |
130 | | - |
131 | | - |
| | |