xref: /NextBSD/contrib/llvm/tools/lldb/include/lldb/Target/ThreadCollection.h (revision 287e3b14e9552995def1802ec9c5034f4adf28ec)
1 //===-- ThreadCollection.h --------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef liblldb_ThreadCollection_h_
11 #define liblldb_ThreadCollection_h_
12 
13 #include <vector>
14 
15 #include "lldb/lldb-private.h"
16 #include "lldb/Host/Mutex.h"
17 #include "lldb/Utility/Iterable.h"
18 
19 namespace lldb_private {
20 
21 class ThreadCollection
22 {
23 public:
24     typedef std::vector<lldb::ThreadSP> collection;
25     typedef LockingAdaptedIterable<collection, lldb::ThreadSP, vector_adapter> ThreadIterable;
26 
27     ThreadCollection();
28 
29     ThreadCollection(collection threads);
30 
31     virtual
~ThreadCollection()32     ~ThreadCollection()
33     {
34     }
35 
36     uint32_t
37     GetSize();
38 
39     void
40     AddThread (const lldb::ThreadSP &thread_sp);
41 
42     void
43     InsertThread (const lldb::ThreadSP &thread_sp, uint32_t idx);
44 
45     // Note that "idx" is not the same as the "thread_index". It is a zero
46     // based index to accessing the current threads, whereas "thread_index"
47     // is a unique index assigned
48     lldb::ThreadSP
49     GetThreadAtIndex (uint32_t idx);
50 
51     virtual ThreadIterable
Threads()52     Threads ()
53     {
54         return ThreadIterable(m_threads, GetMutex());
55     }
56 
57     virtual Mutex &
GetMutex()58     GetMutex()
59     {
60         return m_mutex;
61     }
62 
63 protected:
64     collection m_threads;
65     Mutex m_mutex;
66 };
67 
68 } // namespace lldb_private
69 
70 #endif  // liblldb_ThreadCollection_h_
71