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 #include "vm/thread.h" | 5 #include "vm/thread.h" |
6 | 6 |
7 #include "vm/growable_array.h" | 7 #include "vm/growable_array.h" |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/lockers.h" | 9 #include "vm/lockers.h" |
10 #include "vm/log.h" | 10 #include "vm/log.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 previous->thread_list_next_ = current->thread_list_next_; | 94 previous->thread_list_next_ = current->thread_list_next_; |
95 thread->thread_list_next_ = NULL; | 95 thread->thread_list_next_ = NULL; |
96 return; | 96 return; |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 UNREACHABLE(); | 100 UNREACHABLE(); |
101 } | 101 } |
102 | 102 |
103 | 103 |
| 104 bool Thread::IsThreadInList(ThreadId join_id) { |
| 105 if (join_id == OSThread::kInvalidThreadJoinId) { |
| 106 return false; |
| 107 } |
| 108 ThreadIterator it; |
| 109 while (it.HasNext()) { |
| 110 Thread* t = it.Next(); |
| 111 // An address test is not sufficient because the allocator may recycle |
| 112 // the address for another Thread. Test against the thread's join id. |
| 113 if (t->join_id() == join_id) { |
| 114 return true; |
| 115 } |
| 116 } |
| 117 return false; |
| 118 } |
| 119 |
| 120 |
104 static void DeleteThread(void* thread) { | 121 static void DeleteThread(void* thread) { |
105 delete reinterpret_cast<Thread*>(thread); | 122 delete reinterpret_cast<Thread*>(thread); |
106 } | 123 } |
107 | 124 |
108 | 125 |
109 void Thread::Shutdown() { | 126 void Thread::Shutdown() { |
110 if (thread_list_lock_ != NULL) { | 127 if (thread_list_lock_ != NULL) { |
111 delete thread_list_lock_; | 128 delete thread_list_lock_; |
112 thread_list_lock_ = NULL; | 129 thread_list_lock_ = NULL; |
113 } | 130 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 #else | 188 #else |
172 #define REUSABLE_HANDLE_SCOPE_INIT(object) | 189 #define REUSABLE_HANDLE_SCOPE_INIT(object) |
173 #endif // defined(DEBUG) | 190 #endif // defined(DEBUG) |
174 | 191 |
175 #define REUSABLE_HANDLE_INITIALIZERS(object) \ | 192 #define REUSABLE_HANDLE_INITIALIZERS(object) \ |
176 object##_handle_(NULL), | 193 object##_handle_(NULL), |
177 | 194 |
178 | 195 |
179 Thread::Thread(bool init_vm_constants) | 196 Thread::Thread(bool init_vm_constants) |
180 : id_(OSThread::GetCurrentThreadId()), | 197 : id_(OSThread::GetCurrentThreadId()), |
| 198 join_id_(OSThread::GetCurrentThreadJoinId()), |
181 thread_interrupt_callback_(NULL), | 199 thread_interrupt_callback_(NULL), |
182 thread_interrupt_data_(NULL), | 200 thread_interrupt_data_(NULL), |
183 isolate_(NULL), | 201 isolate_(NULL), |
184 heap_(NULL), | 202 heap_(NULL), |
185 timeline_block_(NULL), | 203 timeline_block_(NULL), |
186 store_buffer_block_(NULL), | 204 store_buffer_block_(NULL), |
187 log_(new class Log()), | 205 log_(new class Log()), |
188 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) | 206 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_INITIALIZERS) |
189 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) | 207 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_INIT) |
190 reusable_handles_(), | 208 reusable_handles_(), |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 Thread* ThreadIterator::Next() { | 561 Thread* ThreadIterator::Next() { |
544 ASSERT(Thread::thread_list_lock_ != NULL); | 562 ASSERT(Thread::thread_list_lock_ != NULL); |
545 ASSERT(Thread::thread_list_lock_->IsOwnedByCurrentThread()); | 563 ASSERT(Thread::thread_list_lock_->IsOwnedByCurrentThread()); |
546 Thread* current = next_; | 564 Thread* current = next_; |
547 next_ = next_->thread_list_next_; | 565 next_ = next_->thread_list_next_; |
548 return current; | 566 return current; |
549 } | 567 } |
550 | 568 |
551 | 569 |
552 } // namespace dart | 570 } // namespace dart |
OLD | NEW |