| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_THREAD_REGISTRY_H_ | 5 #ifndef VM_THREAD_REGISTRY_H_ |
| 6 #define VM_THREAD_REGISTRY_H_ | 6 #define VM_THREAD_REGISTRY_H_ |
| 7 | 7 |
| 8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
| 9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 StackFrameIterator frames_iterator(state.top_exit_frame_info, | 131 StackFrameIterator frames_iterator(state.top_exit_frame_info, |
| 132 validate_frames); | 132 validate_frames); |
| 133 StackFrame* frame = frames_iterator.NextFrame(); | 133 StackFrame* frame = frames_iterator.NextFrame(); |
| 134 while (frame != NULL) { | 134 while (frame != NULL) { |
| 135 frame->VisitObjectPointers(visitor); | 135 frame->VisitObjectPointers(visitor); |
| 136 frame = frames_iterator.NextFrame(); | 136 frame = frames_iterator.NextFrame(); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 private: | 141 void PruneThread(Thread* thread); |
| 142 |
| 142 struct Entry { | 143 struct Entry { |
| 143 // NOTE: |thread| is deleted automatically when the thread exits. | 144 // NOTE: |thread| is deleted automatically when the thread exits. |
| 144 // In other words, it is not safe to dereference |thread| unless you are on | 145 // In other words, it is not safe to dereference |thread| unless you are on |
| 145 // the thread itself. | 146 // the thread itself. |
| 146 Thread* thread; | 147 Thread* thread; |
| 147 bool scheduled; | 148 bool scheduled; |
| 148 Thread::State state; | 149 Thread::State state; |
| 149 }; | 150 }; |
| 150 | 151 |
| 152 class EntryIterator { |
| 153 public: |
| 154 explicit EntryIterator(ThreadRegistry* registry); |
| 155 ~EntryIterator(); |
| 156 |
| 157 // Returns false when there are no more entries. |
| 158 bool HasNext() const; |
| 159 |
| 160 // Returns the next entry and moves forward. |
| 161 const Entry& Next(); |
| 162 |
| 163 private: |
| 164 void Reset(ThreadRegistry* registry); |
| 165 |
| 166 intptr_t index_; |
| 167 ThreadRegistry* registry_; |
| 168 }; |
| 169 |
| 170 private: |
| 151 // Returns Entry corresponding to thread in registry or NULL. | 171 // Returns Entry corresponding to thread in registry or NULL. |
| 152 // Note: Lock should be taken before this function is called. | 172 // Note: Lock should be taken before this function is called. |
| 153 // TODO(koda): Add method Monitor::IsOwnedByCurrentThread. | 173 // TODO(koda): Add method Monitor::IsOwnedByCurrentThread. |
| 154 Entry* FindEntry(Thread* thread) { | 174 Entry* FindEntry(Thread* thread) { |
| 155 for (int i = 0; i < entries_.length(); ++i) { | 175 for (int i = 0; i < entries_.length(); ++i) { |
| 156 if (entries_[i].thread == thread) { | 176 if (entries_[i].thread == thread) { |
| 157 return &entries_[i]; | 177 return &entries_[i]; |
| 158 } | 178 } |
| 159 } | 179 } |
| 160 return NULL; | 180 return NULL; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 175 intptr_t remaining_; // Number of threads yet to reach their safepoint. | 195 intptr_t remaining_; // Number of threads yet to reach their safepoint. |
| 176 int64_t round_; // Counter, to prevent missing updates to remaining_ | 196 int64_t round_; // Counter, to prevent missing updates to remaining_ |
| 177 // (see comments in CheckSafepointLocked). | 197 // (see comments in CheckSafepointLocked). |
| 178 | 198 |
| 179 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry); | 199 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry); |
| 180 }; | 200 }; |
| 181 | 201 |
| 182 } // namespace dart | 202 } // namespace dart |
| 183 | 203 |
| 184 #endif // VM_THREAD_REGISTRY_H_ | 204 #endif // VM_THREAD_REGISTRY_H_ |
| OLD | NEW |