X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=gdb%2Fthread-iter.h;h=169d42a1f0641fa7ce49a043cb55d1d199976739;hb=4c6ee6465acc58f0f86c44668c4e862901186239;hp=446305f0527e633ecde59570ce98b66140c8c784;hpb=080363310650c93ad8e93018bcb6760ba5d32d1c;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/thread-iter.h b/gdb/thread-iter.h index 446305f052..169d42a1f0 100644 --- a/gdb/thread-iter.h +++ b/gdb/thread-iter.h @@ -1,5 +1,5 @@ /* Thread iterators and ranges for GDB, the GNU debugger. - Copyright (C) 2018 Free Software Foundation, Inc. + Copyright (C) 2018-2020 Free Software Foundation, Inc. This file is part of GDB. @@ -19,69 +19,14 @@ #ifndef THREAD_ITER_H #define THREAD_ITER_H -#include "common/filtered-iterator.h" -#include "common/safe-iterator.h" +#include "gdbsupport/filtered-iterator.h" +#include "gdbsupport/next-iterator.h" +#include "gdbsupport/safe-iterator.h" /* A forward iterator that iterates over a given inferior's threads. */ -class inf_threads_iterator -{ -public: - typedef inf_threads_iterator self_type; - typedef struct thread_info *value_type; - typedef struct thread_info *&reference; - typedef struct thread_info **pointer; - typedef std::forward_iterator_tag iterator_category; - typedef int difference_type; - - /* Create an iterator pointing at HEAD. This takes a thread pointer - instead of an inferior pointer to avoid circular dependencies - between the thread and inferior header files. */ - explicit inf_threads_iterator (struct thread_info *head) - : m_thr (head) - {} - - /* Create a one-past-end iterator. */ - inf_threads_iterator () - : m_thr (nullptr) - {} - - inf_threads_iterator& operator++ () - { - m_thr = m_thr->next; - return *this; - } - - thread_info *operator* () const { return m_thr; } - - bool operator!= (const inf_threads_iterator &other) const - { return m_thr != other.m_thr; } - -private: - /* The currently-iterated thread. NULL if we reached the end of the - list. */ - thread_info *m_thr; -}; - -/* A range adapter that makes it possible to iterate over an - inferior's thread list with range-for. */ -template -struct basic_inf_threads_range -{ - friend struct inferior; -private: - explicit basic_inf_threads_range (struct thread_info *head) - : m_head (head) - {} - -public: - Iterator begin () const { return Iterator (m_head); } - Iterator end () const { return Iterator (); } - -private: - thread_info *m_head; -}; +using inf_threads_iterator = next_iterator; /* A forward iterator that iterates over all threads of all inferiors. */ @@ -223,19 +168,19 @@ using safe_inf_threads_iterator of an inferior with range-for. */ using inf_threads_range - = basic_inf_threads_range; + = next_adapter; /* A range adapter that makes it possible to iterate over all non-exited threads of an inferior with range-for. */ using inf_non_exited_threads_range - = basic_inf_threads_range; + = next_adapter; /* A range adapter that makes it possible to iterate over all threads of an inferior with range-for, safely. */ using safe_inf_threads_range - = basic_inf_threads_range; + = next_adapter; /* A range adapter that makes it possible to iterate over all threads of all inferiors with range-for. */