Add a list iterable helper and use it to make a Breakpoint
authorJim Ingham <jingham@apple.com>
Fri, 5 Dec 2014 23:21:30 +0000 (23:21 +0000)
committerJim Ingham <jingham@apple.com>
Fri, 5 Dec 2014 23:21:30 +0000 (23:21 +0000)
iterator in the BreakpointList class.

llvm-svn: 223544

lldb/include/lldb/Breakpoint/BreakpointList.h
lldb/include/lldb/Utility/Iterable.h

index 27f80d0..f4837e1 100644 (file)
@@ -204,11 +204,25 @@ protected:
     bp_collection::const_iterator
     GetBreakpointIDConstIterator(lldb::break_id_t breakID) const;
 
+    Mutex &
+    GetMutex () const
+    {
+        return m_mutex;
+    }
+
     mutable Mutex m_mutex;
     bp_collection m_breakpoints;  // The breakpoint list, currently a list.
     lldb::break_id_t m_next_break_id;
     bool m_is_internal;
 
+public:
+    typedef LockingAdaptedIterable<bp_collection, lldb::BreakpointSP, list_adapter> BreakpointIterable;
+    BreakpointIterable
+    Breakpoints()
+    {
+        return BreakpointIterable(m_breakpoints, GetMutex());
+    }
+
 private:
     DISALLOW_COPY_AND_ASSIGN (BreakpointList);
 };
index 1733537..17c8cf4 100644 (file)
@@ -25,6 +25,11 @@ template <typename I, typename E> E vector_adapter(I &iter)
     return *iter;
 }
     
+template <typename I, typename E> E list_adapter(I &iter)
+{
+    return *iter;
+}
+    
 template <typename C, typename E, E (*A)(typename C::const_iterator &)> class AdaptedConstIterator
 {
 public: