Chromium Code Reviews| 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_ |