7
7
#endif
8
8
9
9
#include < sync.h>
10
- #include < tinyformat.h>
11
10
12
11
#include < logging.h>
12
+ #include < tinyformat.h>
13
13
#include < util/strencodings.h>
14
14
#include < util/threadnames.h>
15
15
16
16
#include < map>
17
17
#include < set>
18
18
#include < system_error>
19
+ #include < utility>
20
+ #include < vector>
19
21
20
22
#ifdef DEBUG_LOCKCONTENTION
21
23
#if !defined(HAVE_THREAD_LOCAL)
@@ -73,7 +75,8 @@ struct CLockLocation {
73
75
int sourceLine;
74
76
};
75
77
76
- typedef std::vector<std::pair<void *, CLockLocation> > LockStack;
78
+ using LockStackItem = std::pair<void *, CLockLocation>;
79
+ using LockStack = std::vector<LockStackItem>;
77
80
typedef std::map<std::pair<void *, void *>, LockStack> LockOrders;
78
81
typedef std::set<std::pair<void *, void *> > InvLockOrders;
79
82
@@ -96,7 +99,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
96
99
{
97
100
LogPrintf (" POTENTIAL DEADLOCK DETECTED\n " );
98
101
LogPrintf (" Previous lock order was:\n " );
99
- for (const std::pair< void *, CLockLocation> & i : s2) {
102
+ for (const LockStackItem & i : s2) {
100
103
if (i.first == mismatch.first ) {
101
104
LogPrintf (" (1)" ); /* Continued */
102
105
}
@@ -106,7 +109,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
106
109
LogPrintf (" %s\n " , i.second .ToString ());
107
110
}
108
111
LogPrintf (" Current lock order is:\n " );
109
- for (const std::pair< void *, CLockLocation> & i : s1) {
112
+ for (const LockStackItem & i : s1) {
110
113
if (i.first == mismatch.first ) {
111
114
LogPrintf (" (1)" ); /* Continued */
112
115
}
@@ -129,7 +132,7 @@ static void push_lock(void* c, const CLockLocation& locklocation)
129
132
130
133
g_lockstack.push_back (std::make_pair (c, locklocation));
131
134
132
- for (const std::pair< void *, CLockLocation> & i : g_lockstack) {
135
+ for (const LockStackItem & i : g_lockstack) {
133
136
if (i.first == c)
134
137
break ;
135
138
@@ -175,14 +178,14 @@ void LeaveCritical()
175
178
std::string LocksHeld ()
176
179
{
177
180
std::string result;
178
- for (const std::pair< void *, CLockLocation> & i : g_lockstack)
181
+ for (const LockStackItem & i : g_lockstack)
179
182
result += i.second .ToString () + std::string (" \n " );
180
183
return result;
181
184
}
182
185
183
186
void AssertLockHeldInternal (const char * pszName, const char * pszFile, int nLine, void * cs)
184
187
{
185
- for (const std::pair< void *, CLockLocation> & i : g_lockstack)
188
+ for (const LockStackItem & i : g_lockstack)
186
189
if (i.first == cs)
187
190
return ;
188
191
tfm::format (std::cerr, " Assertion failed: lock %s not held in %s:%i; locks held:\n %s" , pszName, pszFile, nLine, LocksHeld ());
@@ -191,7 +194,7 @@ void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine,
191
194
192
195
void AssertLockNotHeldInternal (const char * pszName, const char * pszFile, int nLine, void * cs)
193
196
{
194
- for (const std::pair< void *, CLockLocation> & i : g_lockstack) {
197
+ for (const LockStackItem & i : g_lockstack) {
195
198
if (i.first == cs) {
196
199
tfm::format (std::cerr, " Assertion failed: lock %s held in %s:%i; locks held:\n %s" , pszName, pszFile, nLine, LocksHeld ());
197
200
abort ();
0 commit comments