Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(507)

Unified Diff: runtime/vm/thread.h

Issue 1393423005: Add ThreadIterator for iterating over all Threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/thread.cc » ('j') | runtime/vm/thread.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread.h
diff --git a/runtime/vm/thread.h b/runtime/vm/thread.h
index 4b9b9c9c6ba36d48000881410b6b9c330c8835f3..fe13e8d1cf390af2aada5f250e280c9a3ad23f6a 100644
--- a/runtime/vm/thread.h
+++ b/runtime/vm/thread.h
@@ -413,6 +413,15 @@ LEAF_RUNTIME_ENTRY_LIST(DECLARE_MEMBERS)
VMHandles reusable_handles_;
+ // All |Thread|s are registered in the thread list.
+ Thread* thread_list_next_;
+
+ static Thread* thread_list_head_;
+ static Mutex thread_list_lock_;
siva 2015/10/12 23:03:14 In general we avoid declaring a static Mutex like
Cutch 2015/10/13 16:41:23 Done.
+
+ static void AddThreadToList(Thread* thread);
+ static void RemoveThreadFromList(Thread* thread);
siva 2015/10/12 23:03:14 these functions should be private functions to ens
Cutch 2015/10/13 16:41:24 These are private.
+
explicit Thread(bool init_vm_constants = true);
void InitVMConstants();
@@ -446,10 +455,31 @@ REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION)
friend class ApiZone;
friend class Isolate;
friend class StackZone;
+ friend class ThreadIterator;
+ friend class ThreadIteratorTestHelper;
friend class ThreadRegistry;
+
DISALLOW_COPY_AND_ASSIGN(Thread);
};
+
+// Note that this takes the thread list lock, prohibiting threads from coming
+// on- or off-line.
+class ThreadIterator : public ValueObject {
+ public:
+ ThreadIterator();
+ ~ThreadIterator();
+
+ // Returns false when there are no more threads left.
+ bool HasNext();
siva 2015/10/12 23:03:14 bool HasNext() const;
Cutch 2015/10/13 16:41:24 Done.
+
+ // Returns the current thread and moves forward.
+ Thread* Next();
+
+ private:
+ Thread* next_;
+};
+
} // namespace dart
#endif // VM_THREAD_H_
« no previous file with comments | « no previous file | runtime/vm/thread.cc » ('j') | runtime/vm/thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698