2013-12-13 08:29:16 +08:00
|
|
|
//===-- QueueList.cpp -------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-12-13 08:29:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Target/Queue.h"
|
|
|
|
#include "lldb/Target/Process.h"
|
|
|
|
#include "lldb/Target/QueueList.h"
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2016-05-19 13:13:57 +08:00
|
|
|
QueueList::QueueList(Process *process)
|
|
|
|
: m_process(process), m_stop_id(0), m_queues(), m_mutex() {}
|
2013-12-13 08:29:16 +08:00
|
|
|
|
|
|
|
QueueList::~QueueList() { Clear(); }
|
|
|
|
|
|
|
|
uint32_t QueueList::GetSize() {
|
2016-05-19 13:13:57 +08:00
|
|
|
std::lock_guard<std::mutex> guard(m_mutex);
|
2013-12-13 08:29:16 +08:00
|
|
|
return m_queues.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::QueueSP QueueList::GetQueueAtIndex(uint32_t idx) {
|
2016-05-19 13:13:57 +08:00
|
|
|
std::lock_guard<std::mutex> guard(m_mutex);
|
2013-12-13 08:29:16 +08:00
|
|
|
if (idx < m_queues.size()) {
|
|
|
|
return m_queues[idx];
|
|
|
|
} else {
|
|
|
|
return QueueSP();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QueueList::Clear() {
|
2016-05-19 13:13:57 +08:00
|
|
|
std::lock_guard<std::mutex> guard(m_mutex);
|
2013-12-13 08:29:16 +08:00
|
|
|
m_queues.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QueueList::AddQueue(QueueSP queue_sp) {
|
2016-05-19 13:13:57 +08:00
|
|
|
std::lock_guard<std::mutex> guard(m_mutex);
|
2013-12-13 08:29:16 +08:00
|
|
|
if (queue_sp.get()) {
|
|
|
|
m_queues.push_back(queue_sp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::QueueSP QueueList::FindQueueByID(lldb::queue_id_t qid) {
|
|
|
|
QueueSP ret;
|
|
|
|
for (QueueSP queue_sp : Queues()) {
|
|
|
|
if (queue_sp->GetID() == qid) {
|
|
|
|
ret = queue_sp;
|
|
|
|
break;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-12-13 08:29:16 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
lldb::QueueSP QueueList::FindQueueByIndexID(uint32_t index_id) {
|
|
|
|
QueueSP ret;
|
|
|
|
for (QueueSP queue_sp : Queues()) {
|
|
|
|
if (queue_sp->GetIndexID() == index_id) {
|
|
|
|
ret = queue_sp;
|
|
|
|
break;
|
|
|
|
}
|
2016-09-07 04:57:50 +08:00
|
|
|
}
|
2013-12-13 08:29:16 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-05-19 13:13:57 +08:00
|
|
|
std::mutex &QueueList::GetMutex() { return m_mutex; }
|