1 //===-- ThreadSafeDenseSet.h ------------------------------------------*- C++
4 // The LLVM Compiler Infrastructure
6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef liblldb_ThreadSafeDenseSet_h_
12 #define liblldb_ThreadSafeDenseSet_h_
16 #include "llvm/ADT/DenseSet.h"
19 namespace lldb_private {
21 template <typename _ElementType, typename _MutexType = std::mutex>
22 class ThreadSafeDenseSet {
24 typedef llvm::DenseSet<_ElementType> LLVMSetType;
26 ThreadSafeDenseSet(unsigned set_initial_capacity = 0)
27 : m_set(set_initial_capacity), m_mutex() {}
29 void Insert(_ElementType e) {
30 std::lock_guard<_MutexType> guard(m_mutex);
34 void Erase(_ElementType e) {
35 std::lock_guard<_MutexType> guard(m_mutex);
39 bool Lookup(_ElementType e) {
40 std::lock_guard<_MutexType> guard(m_mutex);
41 return (m_set.count(e) > 0);
45 std::lock_guard<_MutexType> guard(m_mutex);
54 } // namespace lldb_private
56 #endif // liblldb_ThreadSafeDenseSet_h_