[Lldb-commits] [lldb] r239865 - Add a ThreadSafe adapter over llvm::DenseSet
Enrico Granata
egranata at apple.com
Tue Jun 16 16:20:12 PDT 2015
Author: enrico
Date: Tue Jun 16 18:20:12 2015
New Revision: 239865
URL: http://llvm.org/viewvc/llvm-project?rev=239865&view=rev
Log:
Add a ThreadSafe adapter over llvm::DenseSet
Added:
lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h
Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj
Added: lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h?rev=239865&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h (added)
+++ lldb/trunk/include/lldb/Core/ThreadSafeDenseSet.h Tue Jun 16 18:20:12 2015
@@ -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_
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=239865&r1=239864&r2=239865&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Jun 16 18:20:12 2015
@@ -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 */,
More information about the lldb-commits
mailing list