LLDB  mainline
ThreadCollection.h
Go to the documentation of this file.
1 //===-- ThreadCollection.h --------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_TARGET_THREADCOLLECTION_H
10 #define LLDB_TARGET_THREADCOLLECTION_H
11 
12 #include <mutex>
13 #include <vector>
14 
15 #include "lldb/Utility/Iterable.h"
16 #include "lldb/lldb-private.h"
17 
18 namespace lldb_private {
19 
21 public:
22  typedef std::vector<lldb::ThreadSP> collection;
23  typedef LockingAdaptedIterable<collection, lldb::ThreadSP, vector_adapter,
24  std::recursive_mutex>
26 
28 
30 
31  virtual ~ThreadCollection() = default;
32 
33  uint32_t GetSize();
34 
35  void AddThread(const lldb::ThreadSP &thread_sp);
36 
37  void AddThreadSortedByIndexID(const lldb::ThreadSP &thread_sp);
38 
39  void InsertThread(const lldb::ThreadSP &thread_sp, uint32_t idx);
40 
41  // Note that "idx" is not the same as the "thread_index". It is a zero based
42  // index to accessing the current threads, whereas "thread_index" is a unique
43  // index assigned
44  lldb::ThreadSP GetThreadAtIndex(uint32_t idx);
45 
46  virtual ThreadIterable Threads() {
48  }
49 
50  virtual std::recursive_mutex &GetMutex() const { return m_mutex; }
51 
52 protected:
54  mutable std::recursive_mutex m_mutex;
55 };
56 
57 } // namespace lldb_private
58 
59 #endif // LLDB_TARGET_THREADCOLLECTION_H
lldb_private::ThreadCollection::GetThreadAtIndex
lldb::ThreadSP GetThreadAtIndex(uint32_t idx)
Definition: ThreadCollection.cpp:59
lldb_private::ThreadCollection::~ThreadCollection
virtual ~ThreadCollection()=default
lldb_private::ThreadCollection::GetSize
uint32_t GetSize()
Definition: ThreadCollection.cpp:54
lldb_private::vector_adapter
E vector_adapter(I &iter)
Definition: Iterable.h:21
lldb_private::ThreadCollection::ThreadIterable
LockingAdaptedIterable< collection, lldb::ThreadSP, vector_adapter, std::recursive_mutex > ThreadIterable
Definition: ThreadCollection.h:25
lldb_private::ThreadCollection::collection
std::vector< lldb::ThreadSP > collection
Definition: ThreadCollection.h:22
lldb_private::ThreadCollection::AddThreadSortedByIndexID
void AddThreadSortedByIndexID(const lldb::ThreadSP &thread_sp)
Definition: ThreadCollection.cpp:29
lldb_private::ThreadCollection::GetMutex
virtual std::recursive_mutex & GetMutex() const
Definition: ThreadCollection.h:50
lldb_private::LockingAdaptedIterable
Definition: Iterable.h:171
lldb_private::ThreadCollection::m_mutex
std::recursive_mutex m_mutex
Definition: ThreadCollection.h:54
lldb_private::ThreadCollection::Threads
virtual ThreadIterable Threads()
Definition: ThreadCollection.h:46
lldb_private::ThreadCollection::ThreadCollection
ThreadCollection()
Definition: ThreadCollection.cpp:19
lldb-private.h
lldb_private::ThreadCollection::InsertThread
void InsertThread(const lldb::ThreadSP &thread_sp, uint32_t idx)
Definition: ThreadCollection.cpp:45
Iterable.h
uint32_t
lldb_private::ThreadCollection
Definition: ThreadCollection.h:20
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::ThreadCollection::AddThread
void AddThread(const lldb::ThreadSP &thread_sp)
Definition: ThreadCollection.cpp:24
lldb_private::ThreadCollection::m_threads
collection m_threads
Definition: ThreadCollection.h:53