ThreadCollection.h revision 278332
1278332Semaste//===-- ThreadCollection.h --------------------------------------*- C++ -*-===//
2278332Semaste//
3278332Semaste//                     The LLVM Compiler Infrastructure
4278332Semaste//
5278332Semaste// This file is distributed under the University of Illinois Open Source
6278332Semaste// License. See LICENSE.TXT for details.
7278332Semaste//
8278332Semaste//===----------------------------------------------------------------------===//
9278332Semaste
10278332Semaste#ifndef liblldb_ThreadCollection_h_
11278332Semaste#define liblldb_ThreadCollection_h_
12278332Semaste
13278332Semaste#include <vector>
14278332Semaste
15278332Semaste#include "lldb/lldb-private.h"
16278332Semaste#include "lldb/Host/Mutex.h"
17278332Semaste#include "lldb/Utility/Iterable.h"
18278332Semaste
19278332Semastenamespace lldb_private {
20278332Semaste
21278332Semasteclass ThreadCollection
22278332Semaste{
23278332Semastepublic:
24278332Semaste    typedef std::vector<lldb::ThreadSP> collection;
25278332Semaste    typedef LockingAdaptedIterable<collection, lldb::ThreadSP, vector_adapter> ThreadIterable;
26278332Semaste
27278332Semaste    ThreadCollection();
28278332Semaste
29278332Semaste    ThreadCollection(collection threads);
30278332Semaste
31278332Semaste    virtual
32278332Semaste    ~ThreadCollection()
33278332Semaste    {
34278332Semaste    }
35278332Semaste
36278332Semaste    uint32_t
37278332Semaste    GetSize();
38278332Semaste
39278332Semaste    void
40278332Semaste    AddThread (const lldb::ThreadSP &thread_sp);
41278332Semaste
42278332Semaste    void
43278332Semaste    InsertThread (const lldb::ThreadSP &thread_sp, uint32_t idx);
44278332Semaste
45278332Semaste    // Note that "idx" is not the same as the "thread_index". It is a zero
46278332Semaste    // based index to accessing the current threads, whereas "thread_index"
47278332Semaste    // is a unique index assigned
48278332Semaste    lldb::ThreadSP
49278332Semaste    GetThreadAtIndex (uint32_t idx);
50278332Semaste
51278332Semaste    virtual ThreadIterable
52278332Semaste    Threads ()
53278332Semaste    {
54278332Semaste        return ThreadIterable(m_threads, GetMutex());
55278332Semaste    }
56278332Semaste
57278332Semaste    virtual Mutex &
58278332Semaste    GetMutex()
59278332Semaste    {
60278332Semaste        return m_mutex;
61278332Semaste    }
62278332Semaste
63278332Semasteprotected:
64278332Semaste    collection m_threads;
65278332Semaste    Mutex m_mutex;
66278332Semaste};
67278332Semaste
68278332Semaste} // namespace lldb_private
69278332Semaste
70278332Semaste#endif  // liblldb_ThreadCollection_h_
71