Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / source / Target / QueueList.cpp
blob84ec24f03f519327608bdeda332200c83c098bf4
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 //===----------------------------------------------------------------------===//
9 #include "lldb/Target/Queue.h"
10 #include "lldb/Target/Process.h"
11 #include "lldb/Target/QueueList.h"
13 using namespace lldb;
14 using namespace lldb_private;
16 QueueList::QueueList(Process *process)
17 : m_process(process), m_stop_id(0), m_queues(), m_mutex() {}
19 QueueList::~QueueList() { Clear(); }
21 uint32_t QueueList::GetSize() {
22 std::lock_guard<std::mutex> guard(m_mutex);
23 return m_queues.size();
26 lldb::QueueSP QueueList::GetQueueAtIndex(uint32_t idx) {
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();
35 void QueueList::Clear() {
36 std::lock_guard<std::mutex> guard(m_mutex);
37 m_queues.clear();
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);
47 lldb::QueueSP QueueList::FindQueueByID(lldb::queue_id_t qid) {
48 QueueSP ret;
49 for (QueueSP queue_sp : Queues()) {
50 if (queue_sp->GetID() == qid) {
51 ret = queue_sp;
52 break;
55 return ret;
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;
66 return ret;
69 std::mutex &QueueList::GetMutex() { return m_mutex; }