aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Target/ThreadCollection.h
blob: 0c2b41cc0ca416b0c258bc1d9386e8af5946c655 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//===-- ThreadCollection.h --------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_ThreadCollection_h_
#define liblldb_ThreadCollection_h_

#include <vector>

#include "lldb/lldb-private.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Utility/Iterable.h"

namespace lldb_private {
    
class ThreadCollection
{
public:
    typedef std::vector<lldb::ThreadSP> collection;
    typedef LockingAdaptedIterable<collection, lldb::ThreadSP, vector_adapter> ThreadIterable;
    
    ThreadCollection();
    
    ThreadCollection(collection threads);
    
    virtual
    ~ThreadCollection()
    {
    }
    
    uint32_t
    GetSize();
    
    void
    AddThread (const lldb::ThreadSP &thread_sp);
    
    void
    InsertThread (const lldb::ThreadSP &thread_sp, uint32_t idx);
    
    // Note that "idx" is not the same as the "thread_index". It is a zero
    // based index to accessing the current threads, whereas "thread_index"
    // is a unique index assigned
    lldb::ThreadSP
    GetThreadAtIndex (uint32_t idx);

    virtual ThreadIterable
    Threads ()
    {
        return ThreadIterable(m_threads, GetMutex());
    }
    
    virtual Mutex &
    GetMutex()
    {
        return m_mutex;
    }
    
protected:
    collection m_threads;
    Mutex m_mutex;
};
    
} // namespace lldb_private

#endif  // liblldb_ThreadCollection_h_