Add a ThreadSafe adapter over llvm::DenseSet

llvm-svn: 239865
This commit is contained in:
Enrico Granata 2015-06-16 23:20:12 +00:00
parent 6592ff8c93
commit 55d36e2b83
2 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,65 @@
//===-- ThreadSafeDenseSet.h ------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_ThreadSafeDenseSet_h_
#define liblldb_ThreadSafeDenseSet_h_
// C Includes
// C++ Includes
// Other libraries and framework includes
#include "llvm/ADT/DenseSet.h"
// Project includes
#include "lldb/Host/Mutex.h"
namespace lldb_private {
template <typename _ElementType>
class ThreadSafeDenseSet
{
public:
typedef llvm::DenseSet<_ElementType> LLVMSetType;
ThreadSafeDenseSet(unsigned set_initial_capacity = 0,
Mutex::Type mutex_type = Mutex::eMutexTypeNormal) :
m_set(set_initial_capacity),
m_mutex(mutex_type)
{
}
void
Insert (_ElementType e)
{
Mutex::Locker locker(m_mutex);
m_set.insert(e);
}
void
Erase (_ElementType e)
{
Mutex::Locker locker(m_mutex);
m_set.erase(e);
}
bool
Lookup (_ElementType e)
{
Mutex::Locker locker(m_mutex);
return (m_set.count(e) > 0);
}
protected:
LLVMSetType m_set;
Mutex m_mutex;
};
} // namespace lldb_private
#endif // liblldb_ThreadSafeDenseSet_h_

View File

@ -2498,6 +2498,7 @@
944372DB171F6B4300E57C32 /* RegisterContextDummy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RegisterContextDummy.h; path = Utility/RegisterContextDummy.h; sourceTree = "<group>"; };
9443B120140C18A90013457C /* SBData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBData.h; path = include/lldb/API/SBData.h; sourceTree = "<group>"; };
9443B121140C18C10013457C /* SBData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBData.cpp; path = source/API/SBData.cpp; sourceTree = "<group>"; };
9449B8031B30E0690019342B /* ThreadSafeDenseSet.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ThreadSafeDenseSet.h; path = include/lldb/Core/ThreadSafeDenseSet.h; sourceTree = "<group>"; };
944DC3481774C99000D7D884 /* python-swigsafecast.swig */ = {isa = PBXFileReference; lastKnownFileType = text; path = "python-swigsafecast.swig"; sourceTree = "<group>"; };
945215DD17F639E600521C0B /* ValueObjectPrinter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ValueObjectPrinter.h; path = include/lldb/DataFormatters/ValueObjectPrinter.h; sourceTree = "<group>"; };
945215DE17F639EE00521C0B /* ValueObjectPrinter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectPrinter.cpp; path = source/DataFormatters/ValueObjectPrinter.cpp; sourceTree = "<group>"; };
@ -4140,6 +4141,7 @@
26BC7D7E10F1B77400F91463 /* Timer.h */,
26BC7E9610F1B85900F91463 /* Timer.cpp */,
94ED54A119C8A822007BE2EA /* ThreadSafeDenseMap.h */,
9449B8031B30E0690019342B /* ThreadSafeDenseSet.h */,
268A813F115B19D000F645B0 /* UniqueCStringMap.h */,
26BC7D8010F1B77400F91463 /* UserID.h */,
26BC7E9810F1B85900F91463 /* UserID.cpp */,