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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 } | 118 } |
119 | 119 |
120 | 120 |
121 static void DeleteThread(void* thread) { | 121 static void DeleteThread(void* thread) { |
122 delete reinterpret_cast<Thread*>(thread); | 122 delete reinterpret_cast<Thread*>(thread); |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 void Thread::Shutdown() { | 126 void Thread::Shutdown() { |
127 if (thread_list_lock_ != NULL) { | 127 if (thread_list_lock_ != NULL) { |
128 Thread* thread = Current(); | |
129 ASSERT(thread != NULL); | |
130 delete thread; | |
131 thread = NULL; | |
132 SetCurrent(NULL); | |
133 OSThread::DeleteThreadLocal(thread_key_); | |
Cutch
2015/10/28 20:33:15
Can we move this TLS cleanup below the ASSERT.
O
zra
2015/10/28 21:40:04
Moved.
| |
134 thread_key_ = OSThread::kUnsetThreadLocalKey; | |
135 | |
136 // Check that there are no more threads, then delete the lock. | |
137 { | |
138 MutexLocker ml(thread_list_lock_); | |
139 ASSERT(thread_list_head_ == NULL); | |
140 } | |
128 delete thread_list_lock_; | 141 delete thread_list_lock_; |
129 thread_list_lock_ = NULL; | 142 thread_list_lock_ = NULL; |
130 } | 143 } |
131 } | 144 } |
132 | 145 |
133 | 146 |
134 Thread::~Thread() { | 147 Thread::~Thread() { |
135 // We should cleanly exit any isolate before destruction. | 148 // We should cleanly exit any isolate before destruction. |
136 ASSERT(isolate_ == NULL); | 149 ASSERT(isolate_ == NULL); |
137 // Clear |this| from all isolate's thread registry. | 150 // Clear |this| from all isolate's thread registry. |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 Thread* ThreadIterator::Next() { | 579 Thread* ThreadIterator::Next() { |
567 ASSERT(Thread::thread_list_lock_ != NULL); | 580 ASSERT(Thread::thread_list_lock_ != NULL); |
568 ASSERT(Thread::thread_list_lock_->IsOwnedByCurrentThread()); | 581 ASSERT(Thread::thread_list_lock_->IsOwnedByCurrentThread()); |
569 Thread* current = next_; | 582 Thread* current = next_; |
570 next_ = next_->thread_list_next_; | 583 next_ = next_->thread_list_next_; |
571 return current; | 584 return current; |
572 } | 585 } |
573 | 586 |
574 | 587 |
575 } // namespace dart | 588 } // namespace dart |
OLD | NEW |