Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===-- QueueList.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_QUEUELIST_H
0010 #define LLDB_TARGET_QUEUELIST_H
0011 
0012 #include <mutex>
0013 #include <vector>
0014 
0015 #include "lldb/Utility/Iterable.h"
0016 #include "lldb/Utility/UserID.h"
0017 #include "lldb/lldb-private.h"
0018 
0019 namespace lldb_private {
0020 
0021 // QueueList:
0022 // This is the container for libdispatch aka Grand Central Dispatch Queue
0023 // objects.
0024 //
0025 // Each Process will have a QueueList.  When the process execution is paused,
0026 // the QueueList may be populated with Queues by the SystemRuntime.
0027 
0028 class QueueList {
0029   friend class Process;
0030 
0031 public:
0032   QueueList(Process *process);
0033 
0034   ~QueueList();
0035 
0036   /// Get the number of libdispatch queues that are available
0037   ///
0038   /// \return
0039   ///     The number of queues that are stored in the QueueList.
0040   uint32_t GetSize();
0041 
0042   /// Get the Queue at a given index number
0043   ///
0044   /// \param [in] idx
0045   ///     The index number (0-based) of the queue.
0046   /// \return
0047   ///     The Queue at that index number.
0048   lldb::QueueSP GetQueueAtIndex(uint32_t idx);
0049 
0050   typedef std::vector<lldb::QueueSP> collection;
0051   typedef LockingAdaptedIterable<collection, lldb::QueueSP, vector_adapter,
0052                                  std::mutex>
0053       QueueIterable;
0054 
0055   /// Iterate over the list of queues
0056   ///
0057   /// \return
0058   ///     An Iterable object which can be used to loop over the queues
0059   ///     that exist.
0060   QueueIterable Queues() { return QueueIterable(m_queues, m_mutex); }
0061 
0062   /// Clear out the list of queues from the QueueList
0063   void Clear();
0064 
0065   /// Add a Queue to the QueueList
0066   ///
0067   /// \param [in] queue
0068   ///     Used by the SystemRuntime to populate the QueueList
0069   void AddQueue(lldb::QueueSP queue);
0070 
0071   /// Find a queue in the QueueList by QueueID
0072   ///
0073   /// \param [in] qid
0074   ///     The QueueID (same as returned by Thread::GetQueueID()) to find.
0075   ///
0076   /// \return
0077   ///     A QueueSP to the queue requested, if it is present in the QueueList.
0078   ///     An empty QueueSP will be returned if this queue was not found.
0079   lldb::QueueSP FindQueueByID(lldb::queue_id_t qid);
0080 
0081   /// Find a queue in the QueueList by IndexID
0082   ///
0083   /// \param [in] index_id
0084   ///     Find a queue by IndexID.  This is an integer associated with each
0085   ///     unique queue seen during a debug session and will not be reused
0086   ///     for a different queue.  Unlike the QueueID, a 64-bit value, this
0087   ///     will tend to be an integral value like 1 or 7.
0088   ///
0089   /// \return
0090   ///     A QueueSP to the queue requested, if it is present in the QueueList.
0091   ///     An empty QueueSP will be returned if this queue was not found.
0092   lldb::QueueSP FindQueueByIndexID(uint32_t index_id);
0093 
0094   std::mutex &GetMutex();
0095 
0096 protected:
0097   // Classes that inherit from Process can see and modify these
0098   Process *m_process; ///< The process that manages this queue list.
0099   uint32_t
0100       m_stop_id; ///< The process stop ID that this queue list is valid for.
0101   collection m_queues; ///< The queues for this process.
0102   std::mutex m_mutex;
0103 
0104 private:
0105   QueueList() = delete;
0106 };
0107 
0108 } // namespace lldb_private
0109 
0110 #endif // LLDB_TARGET_QUEUELIST_H