Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:55

0001 //===-- ThreadCollection.h --------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_TARGET_THREADCOLLECTION_H
0010 #define LLDB_TARGET_THREADCOLLECTION_H
0011 
0012 #include <mutex>
0013 #include <vector>
0014 
0015 #include "lldb/Utility/Iterable.h"
0016 #include "lldb/lldb-private.h"
0017 
0018 namespace lldb_private {
0019 
0020 class ThreadCollection {
0021 public:
0022   typedef std::vector<lldb::ThreadSP> collection;
0023   typedef LockingAdaptedIterable<collection, lldb::ThreadSP, vector_adapter,
0024                                  std::recursive_mutex>
0025       ThreadIterable;
0026 
0027   ThreadCollection();
0028 
0029   ThreadCollection(collection threads);
0030 
0031   virtual ~ThreadCollection() = default;
0032 
0033   uint32_t GetSize();
0034 
0035   void AddThread(const lldb::ThreadSP &thread_sp);
0036 
0037   void AddThreadSortedByIndexID(const lldb::ThreadSP &thread_sp);
0038 
0039   void InsertThread(const lldb::ThreadSP &thread_sp, uint32_t idx);
0040 
0041   // Note that "idx" is not the same as the "thread_index". It is a zero based
0042   // index to accessing the current threads, whereas "thread_index" is a unique
0043   // index assigned
0044   lldb::ThreadSP GetThreadAtIndex(uint32_t idx);
0045 
0046   virtual ThreadIterable Threads() {
0047     return ThreadIterable(m_threads, GetMutex());
0048   }
0049 
0050   virtual std::recursive_mutex &GetMutex() const { return m_mutex; }
0051 
0052 protected:
0053   collection m_threads;
0054   mutable std::recursive_mutex m_mutex;
0055 };
0056 
0057 } // namespace lldb_private
0058 
0059 #endif // LLDB_TARGET_THREADCOLLECTION_H