Skip to content

Commit

Permalink
Add a few useful methods to ThreadSafeDense{Map,Set}. Not used yet.
Browse files Browse the repository at this point in the history
llvm-svn: 252031
  • Loading branch information
jimingham committed Nov 4, 2015
1 parent ff836df commit 5d07293
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lldb/include/lldb/Core/ThreadSafeDenseMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,27 @@ class ThreadSafeDenseMap
Mutex::Locker locker(m_mutex);
return m_map.lookup(k);
}


bool
Lookup (_KeyType k,
_ValueType& v)
{
Mutex::Locker locker(m_mutex);
auto iter = m_map.find(k),
end = m_map.end();
if (iter == end)
return false;
v = iter->second;
return true;
}

void
Clear ()
{
Mutex::Locker locker(m_mutex);
m_map.clear();
}

protected:
LLVMMapType m_map;
Mutex m_mutex;
Expand Down
7 changes: 7 additions & 0 deletions lldb/include/lldb/Core/ThreadSafeDenseSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ namespace lldb_private {
return (m_set.count(e) > 0);
}

void
Clear ()
{
Mutex::Locker locker(m_mutex);
m_set.clear();
}

protected:
LLVMSetType m_set;
Mutex m_mutex;
Expand Down

0 comments on commit 5d07293

Please sign in to comment.