| Index: runtime/vm/thread.h
|
| diff --git a/runtime/vm/thread.h b/runtime/vm/thread.h
|
| index 4b9b9c9c6ba36d48000881410b6b9c330c8835f3..96c9a6389c555338a7c55e20e356b673c7cbacc8 100644
|
| --- a/runtime/vm/thread.h
|
| +++ b/runtime/vm/thread.h
|
| @@ -153,6 +153,8 @@ class Thread {
|
| static void InitOnceBeforeIsolate();
|
| static void InitOnceAfterObjectAndStubCode();
|
|
|
| + // Called at VM shutdown
|
| + static void Shutdown();
|
| ~Thread();
|
|
|
| // The topmost zone used for allocation in this thread.
|
| @@ -413,6 +415,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_;
|
| +
|
| + static void AddThreadToList(Thread* thread);
|
| + static void RemoveThreadFromList(Thread* thread);
|
| +
|
| explicit Thread(bool init_vm_constants = true);
|
|
|
| void InitVMConstants();
|
| @@ -446,10 +457,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() const;
|
| +
|
| + // Returns the current thread and moves forward.
|
| + Thread* Next();
|
| +
|
| + private:
|
| + Thread* next_;
|
| +};
|
| +
|
| } // namespace dart
|
|
|
| #endif // VM_THREAD_H_
|
|
|