1 //===-- QueueList.cpp -------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Target/Queue.h"
11 #include "lldb/Target/Process.h"
12 #include "lldb/Target/QueueList.h"
15 using namespace lldb_private;
17 QueueList::QueueList(Process *process)
18 : m_process(process), m_stop_id(0), m_queues(), m_mutex() {}
20 QueueList::~QueueList() { Clear(); }
22 uint32_t QueueList::GetSize() {
23 std::lock_guard<std::mutex> guard(m_mutex);
24 return m_queues.size();
27 lldb::QueueSP QueueList::GetQueueAtIndex(uint32_t idx) {
28 std::lock_guard<std::mutex> guard(m_mutex);
29 if (idx < m_queues.size()) {
36 void QueueList::Clear() {
37 std::lock_guard<std::mutex> guard(m_mutex);
41 void QueueList::AddQueue(QueueSP queue_sp) {
42 std::lock_guard<std::mutex> guard(m_mutex);
44 m_queues.push_back(queue_sp);
48 lldb::QueueSP QueueList::FindQueueByID(lldb::queue_id_t qid) {
50 for (QueueSP queue_sp : Queues()) {
51 if (queue_sp->GetID() == qid) {
59 lldb::QueueSP QueueList::FindQueueByIndexID(uint32_t index_id) {
61 for (QueueSP queue_sp : Queues()) {
62 if (queue_sp->GetIndexID() == index_id) {
70 std::mutex &QueueList::GetMutex() { return m_mutex; }