1 //===-- ThreadCollection.h --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_ThreadCollection_h_
11 #define liblldb_ThreadCollection_h_
16 #include "lldb/Utility/Iterable.h"
17 #include "lldb/lldb-private.h"
19 namespace lldb_private {
21 class ThreadCollection {
23 typedef std::vector<lldb::ThreadSP> collection;
24 typedef LockingAdaptedIterable<collection, lldb::ThreadSP, vector_adapter,
30 ThreadCollection(collection threads);
32 virtual ~ThreadCollection() {}
36 void AddThread(const lldb::ThreadSP &thread_sp);
38 void AddThreadSortedByIndexID(const lldb::ThreadSP &thread_sp);
40 void InsertThread(const lldb::ThreadSP &thread_sp, uint32_t idx);
42 // Note that "idx" is not the same as the "thread_index". It is a zero
43 // based index to accessing the current threads, whereas "thread_index"
44 // is a unique index assigned
45 lldb::ThreadSP GetThreadAtIndex(uint32_t idx);
47 virtual ThreadIterable Threads() {
48 return ThreadIterable(m_threads, GetMutex());
51 virtual std::recursive_mutex &GetMutex() const { return m_mutex; }
55 mutable std::recursive_mutex m_mutex;
58 } // namespace lldb_private
60 #endif // liblldb_ThreadCollection_h_