Path: blob/main/contrib/llvm-project/lldb/source/Target/QueueList.cpp
39587 views
//===-- QueueList.cpp -----------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/Target/Queue.h"9#include "lldb/Target/Process.h"10#include "lldb/Target/QueueList.h"1112using namespace lldb;13using namespace lldb_private;1415QueueList::QueueList(Process *process)16: m_process(process), m_stop_id(0), m_queues(), m_mutex() {}1718QueueList::~QueueList() { Clear(); }1920uint32_t QueueList::GetSize() {21std::lock_guard<std::mutex> guard(m_mutex);22return m_queues.size();23}2425lldb::QueueSP QueueList::GetQueueAtIndex(uint32_t idx) {26std::lock_guard<std::mutex> guard(m_mutex);27if (idx < m_queues.size()) {28return m_queues[idx];29} else {30return QueueSP();31}32}3334void QueueList::Clear() {35std::lock_guard<std::mutex> guard(m_mutex);36m_queues.clear();37}3839void QueueList::AddQueue(QueueSP queue_sp) {40std::lock_guard<std::mutex> guard(m_mutex);41if (queue_sp.get()) {42m_queues.push_back(queue_sp);43}44}4546lldb::QueueSP QueueList::FindQueueByID(lldb::queue_id_t qid) {47QueueSP ret;48for (QueueSP queue_sp : Queues()) {49if (queue_sp->GetID() == qid) {50ret = queue_sp;51break;52}53}54return ret;55}5657lldb::QueueSP QueueList::FindQueueByIndexID(uint32_t index_id) {58QueueSP ret;59for (QueueSP queue_sp : Queues()) {60if (queue_sp->GetIndexID() == index_id) {61ret = queue_sp;62break;63}64}65return ret;66}6768std::mutex &QueueList::GetMutex() { return m_mutex; }697071