LLDB  mainline
QueueList.cpp
Go to the documentation of this file.
1 //===-- QueueList.cpp -----------------------------------------------------===//
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 #include "lldb/Target/Queue.h"
10 #include "lldb/Target/Process.h"
11 #include "lldb/Target/QueueList.h"
12 
13 using namespace lldb;
14 using namespace lldb_private;
15 
16 QueueList::QueueList(Process *process)
17  : m_process(process), m_stop_id(0), m_queues(), m_mutex() {}
18 
20 
22  std::lock_guard<std::mutex> guard(m_mutex);
23  return m_queues.size();
24 }
25 
27  std::lock_guard<std::mutex> guard(m_mutex);
28  if (idx < m_queues.size()) {
29  return m_queues[idx];
30  } else {
31  return QueueSP();
32  }
33 }
34 
36  std::lock_guard<std::mutex> guard(m_mutex);
37  m_queues.clear();
38 }
39 
40 void QueueList::AddQueue(QueueSP queue_sp) {
41  std::lock_guard<std::mutex> guard(m_mutex);
42  if (queue_sp.get()) {
43  m_queues.push_back(queue_sp);
44  }
45 }
46 
48  QueueSP ret;
49  for (QueueSP queue_sp : Queues()) {
50  if (queue_sp->GetID() == qid) {
51  ret = queue_sp;
52  break;
53  }
54  }
55  return ret;
56 }
57 
58 lldb::QueueSP QueueList::FindQueueByIndexID(uint32_t index_id) {
59  QueueSP ret;
60  for (QueueSP queue_sp : Queues()) {
61  if (queue_sp->GetIndexID() == index_id) {
62  ret = queue_sp;
63  break;
64  }
65  }
66  return ret;
67 }
68 
69 std::mutex &QueueList::GetMutex() { return m_mutex; }
lldb_private::QueueList::m_queues
collection m_queues
The queues for this process.
Definition: QueueList.h:101
lldb_private::QueueList::Queues
QueueIterable Queues()
Iterate over the list of queues.
Definition: QueueList.h:60
lldb_private::QueueList::GetSize
uint32_t GetSize()
Get the number of libdispatch queues that are available.
Definition: QueueList.cpp:21
lldb_private::Process
Definition: Process.h:341
lldb_private::QueueList::AddQueue
void AddQueue(lldb::QueueSP queue)
Add a Queue to the QueueList.
Definition: QueueList.cpp:40
Process.h
lldb::queue_id_t
uint64_t queue_id_t
Definition: lldb-types.h:91
lldb_private::QueueList::GetQueueAtIndex
lldb::QueueSP GetQueueAtIndex(uint32_t idx)
Get the Queue at a given index number.
Definition: QueueList.cpp:26
lldb_private::QueueList::GetMutex
std::mutex & GetMutex()
Definition: QueueList.cpp:69
lldb_private::QueueList::m_mutex
std::mutex m_mutex
Definition: QueueList.h:102
Queue.h
lldb_private::QueueList::FindQueueByID
lldb::QueueSP FindQueueByID(lldb::queue_id_t qid)
Find a queue in the QueueList by QueueID.
Definition: QueueList.cpp:47
uint32_t
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::QueueList::FindQueueByIndexID
lldb::QueueSP FindQueueByIndexID(uint32_t index_id)
Find a queue in the QueueList by IndexID.
Definition: QueueList.cpp:58
lldb_private::QueueList::~QueueList
~QueueList()
Definition: QueueList.cpp:19
lldb_private::QueueList::Clear
void Clear()
Clear out the list of queues from the QueueList.
Definition: QueueList.cpp:35
lldb
Definition: SBAddress.h:15
QueueList.h