Fix race in setThreadName/getThreadName

This commit is contained in:
Lee Clagett 2017-02-07 21:33:26 -05:00
parent 3473af00ad
commit 6ea3e3ccc7

View file

@ -3988,10 +3988,12 @@ inline void FUNCTION_NAME(const T&);
}
void setThreadName(const std::string &name) {
const base::threading::ScopedLock scopedLock(lock());
m_threadNames[base::threading::getCurrentThreadId()] = name;
}
std::string getThreadName(const std::string& name) {
const base::threading::ScopedLock scopedLock(lock());
std::map<std::string, std::string>::const_iterator it = m_threadNames.find(name);
if (it == m_threadNames.end())
return name;