1 //===-- QueueList.cpp -------------------------------------------*- 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 #include "lldb/Target/Queue.h" 11 #include "lldb/Target/Process.h" 12 #include "lldb/Target/QueueList.h" 13 14 using namespace lldb; 15 using namespace lldb_private; 16 17 QueueList::QueueList(Process *process) 18 : m_process(process), m_stop_id(0), m_queues(), m_mutex() {} 19 20 QueueList::~QueueList() { Clear(); } 21 22 uint32_t QueueList::GetSize() { 23 std::lock_guard<std::mutex> guard(m_mutex); 24 return m_queues.size(); 25 } 26 27 lldb::QueueSP QueueList::GetQueueAtIndex(uint32_t idx) { 28 std::lock_guard<std::mutex> guard(m_mutex); 29 if (idx < m_queues.size()) { 30 return m_queues[idx]; 31 } else { 32 return QueueSP(); 33 } 34 } 35 36 void QueueList::Clear() { 37 std::lock_guard<std::mutex> guard(m_mutex); 38 m_queues.clear(); 39 } 40 41 void QueueList::AddQueue(QueueSP queue_sp) { 42 std::lock_guard<std::mutex> guard(m_mutex); 43 if (queue_sp.get()) { 44 m_queues.push_back(queue_sp); 45 } 46 } 47 48 lldb::QueueSP QueueList::FindQueueByID(lldb::queue_id_t qid) { 49 QueueSP ret; 50 for (QueueSP queue_sp : Queues()) { 51 if (queue_sp->GetID() == qid) { 52 ret = queue_sp; 53 break; 54 } 55 } 56 return ret; 57 } 58 59 lldb::QueueSP QueueList::FindQueueByIndexID(uint32_t index_id) { 60 QueueSP ret; 61 for (QueueSP queue_sp : Queues()) { 62 if (queue_sp->GetIndexID() == index_id) { 63 ret = queue_sp; 64 break; 65 } 66 } 67 return ret; 68 } 69 70 std::mutex &QueueList::GetMutex() { return m_mutex; } 71