diff options
Diffstat (limited to 'source/Target/ThreadCollection.cpp')
-rw-r--r-- | source/Target/ThreadCollection.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/source/Target/ThreadCollection.cpp b/source/Target/ThreadCollection.cpp new file mode 100644 index 000000000000..dc1e38e02420 --- /dev/null +++ b/source/Target/ThreadCollection.cpp @@ -0,0 +1,62 @@ +//===-- ThreadCollection.cpp ------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include <stdlib.h> + +#include <algorithm> + +#include "lldb/Target/ThreadCollection.h" + +using namespace lldb; +using namespace lldb_private; + +ThreadCollection::ThreadCollection() : + m_threads(), + m_mutex() +{ +} + +ThreadCollection::ThreadCollection(collection threads) : + m_threads(threads), + m_mutex() +{ +} + +void +ThreadCollection::AddThread (const ThreadSP &thread_sp) +{ + Mutex::Locker locker(GetMutex()); + m_threads.push_back (thread_sp); +} + +void +ThreadCollection::InsertThread (const lldb::ThreadSP &thread_sp, uint32_t idx) +{ + Mutex::Locker locker(GetMutex()); + if (idx < m_threads.size()) + m_threads.insert(m_threads.begin() + idx, thread_sp); + else + m_threads.push_back (thread_sp); +} + +uint32_t +ThreadCollection::GetSize () +{ + Mutex::Locker locker(GetMutex()); + return m_threads.size(); +} + +ThreadSP +ThreadCollection::GetThreadAtIndex (uint32_t idx) +{ + Mutex::Locker locker(GetMutex()); + ThreadSP thread_sp; + if (idx < m_threads.size()) + thread_sp = m_threads[idx]; + return thread_sp; +} |