brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 84ec24f Raw
70 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9#include "lldb/Target/Queue.h"10#include "lldb/Target/Process.h"11#include "lldb/Target/QueueList.h"12 13using namespace lldb;14using namespace lldb_private;15 16QueueList::QueueList(Process *process)17    : m_process(process), m_stop_id(0), m_queues(), m_mutex() {}18 19QueueList::~QueueList() { Clear(); }20 21uint32_t QueueList::GetSize() {22  std::lock_guard<std::mutex> guard(m_mutex);23  return m_queues.size();24}25 26lldb::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();32  }33}34 35void QueueList::Clear() {36  std::lock_guard<std::mutex> guard(m_mutex);37  m_queues.clear();38}39 40void 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 47lldb::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;53    }54  }55  return ret;56}57 58lldb::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 69std::mutex &QueueList::GetMutex() { return m_mutex; }70