44
55#include < sync.h>
66
7+ #include < set>
78#include < util.h>
89#include < utilstrencodings.h>
910
1011#include < stdio.h>
1112
12- #include < boost/thread.hpp>
13-
1413#ifdef DEBUG_LOCKCONTENTION
1514void PrintLockContention (const char * pszName, const char * pszFile, int nLine)
1615{
@@ -45,8 +44,8 @@ struct CLockLocation {
4544 return mutexName + " " + sourceFile + " :" + itostr (sourceLine) + (fTry ? " (TRY)" : " " );
4645 }
4746
48- bool fTry ;
4947private:
48+ bool fTry ;
5049 std::string mutexName;
5150 std::string sourceFile;
5251 int sourceLine;
@@ -67,10 +66,10 @@ struct LockData {
6766
6867 LockOrders lockorders;
6968 InvLockOrders invlockorders;
70- boost ::mutex dd_mutex;
69+ std ::mutex dd_mutex;
7170} static lockdata;
7271
73- boost::thread_specific_ptr <LockStack> lockstack;
72+ static thread_local std::unique_ptr <LockStack> lockstack;
7473
7574static void potential_deadlock_detected (const std::pair<void *, void *>& mismatch, const LockStack& s1, const LockStack& s2)
7675{
@@ -100,12 +99,12 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
10099
101100static void push_lock (void * c, const CLockLocation& locklocation)
102101{
103- if (lockstack. get () == nullptr )
102+ if (! lockstack)
104103 lockstack.reset (new LockStack);
105104
106- boost::unique_lock<boost ::mutex> lock (lockdata.dd_mutex );
105+ std::lock_guard<std ::mutex> lock (lockdata.dd_mutex );
107106
108- (* lockstack). push_back (std::make_pair (c, locklocation));
107+ lockstack-> push_back (std::make_pair (c, locklocation));
109108
110109 for (const std::pair<void *, CLockLocation> & i : (*lockstack)) {
111110 if (i.first == c)
@@ -171,7 +170,7 @@ void DeleteLock(void* cs)
171170 // We're already shutting down.
172171 return ;
173172 }
174- boost::unique_lock<boost ::mutex> lock (lockdata.dd_mutex );
173+ std::lock_guard<std ::mutex> lock (lockdata.dd_mutex );
175174 std::pair<void *, void *> item = std::make_pair (cs, nullptr );
176175 LockOrders::iterator it = lockdata.lockorders .lower_bound (item);
177176 while (it != lockdata.lockorders .end () && it->first .first == cs) {
0 commit comments