]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/include/lldb/Target/QueueList.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / include / lldb / Target / QueueList.h
1 //===-- QueueList.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_QueueList_h_
11 #define liblldb_QueueList_h_
12
13 #include <vector>
14
15 #include "lldb/lldb-private.h"
16 #include "lldb/Core/UserID.h"
17 #include "lldb/Utility/Iterable.h"
18
19
20 namespace lldb_private {
21
22 //------------------------------------------------------------------
23 // QueueList:
24 // This is the container for libdispatch aka Grand Central Dispatch 
25 // Queue objects.
26 //
27 // Each Process will have a QueueList.  When the process execution is
28 // paused, the QueueList may be populated with Queues by the 
29 // SystemRuntime.
30 //------------------------------------------------------------------
31
32 class QueueList
33 {
34 friend class Process;
35
36 public:
37
38     QueueList (Process *process);
39
40     ~QueueList ();
41
42     //------------------------------------------------------------------
43     /// Get the number of libdispatch queues that are available
44     ///
45     /// @return
46     ///     The number of queues that are stored in the QueueList.
47     //------------------------------------------------------------------
48     uint32_t
49     GetSize();
50
51     //------------------------------------------------------------------
52     /// Get the Queue at a given index number
53     ///
54     /// @param [in] idx
55     ///     The index number (0-based) of the queue.
56     /// @return
57     ///     The Queue at that index number.
58     //------------------------------------------------------------------
59     lldb::QueueSP
60     GetQueueAtIndex (uint32_t idx);
61
62     typedef std::vector<lldb::QueueSP> collection;
63     typedef LockingAdaptedIterable<collection, lldb::QueueSP, vector_adapter> QueueIterable;
64
65     //------------------------------------------------------------------
66     /// Iterate over the list of queues
67     ///
68     /// @return
69     ///     An Iterable object which can be used to loop over the queues
70     ///     that exist.
71     //------------------------------------------------------------------
72     QueueIterable
73     Queues ()
74     {
75         return QueueIterable(m_queues, m_mutex);
76     }
77
78     //------------------------------------------------------------------
79     /// Clear out the list of queues from the QueueList
80     //------------------------------------------------------------------
81     void
82     Clear();
83
84     //------------------------------------------------------------------
85     /// Add a Queue to the QueueList
86     ///
87     /// @param [in] queue
88     ///     Used by the SystemRuntime to populate the QueueList
89     //------------------------------------------------------------------
90     void
91     AddQueue (lldb::QueueSP queue);
92
93     //------------------------------------------------------------------
94     /// Find a queue in the QueueList by QueueID
95     ///
96     /// @param [in] qid
97     ///     The QueueID (same as returned by Thread::GetQueueID()) to find.
98     ///
99     /// @return
100     ///     A QueueSP to the queue requested, if it is present in the QueueList.
101     ///     An empty QueueSP willbe returned if this queue was not found.
102     //------------------------------------------------------------------
103     lldb::QueueSP
104     FindQueueByID (lldb::queue_id_t qid);
105
106     //------------------------------------------------------------------
107     /// Find a queue in the QueueList by IndexID
108     ///
109     /// @param [in] index_id
110     ///     Find a queue by IndexID.  This is an integer associated with each
111     ///     unique queue seen during a debug session and will not be reused
112     ///     for a different queue.  Unlike the QueueID, a 64-bit value, this
113     ///     will tend to be an integral value like 1 or 7.
114     ///
115     /// @return
116     ///     A QueueSP to the queue requested, if it is present in the QueueList.
117     ///     An empty QueueSP willbe returned if this queue was not found.
118     //------------------------------------------------------------------
119     lldb::QueueSP
120     FindQueueByIndexID (uint32_t index_id);
121
122     lldb_private::Mutex &
123     GetMutex ();
124
125 protected:
126
127     //------------------------------------------------------------------
128     // Classes that inherit from Process can see and modify these
129     //------------------------------------------------------------------
130     Process *m_process; ///< The process that manages this queue list.
131     uint32_t m_stop_id; ///< The process stop ID that this queue list is valid for.
132     collection m_queues; ///< The queues for this process.
133     Mutex   m_mutex;
134
135 private:
136     QueueList ();
137 };
138
139 } // namespace lldb_private
140
141 #endif  // liblldb_QueueList_h_