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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 void Thread::EnsureInit() { | 158 void Thread::EnsureInit() { |
159 if (Thread::Current() == NULL) { | 159 if (Thread::Current() == NULL) { |
160 // Allocate a new Thread. | 160 // Allocate a new Thread. |
161 Thread* thread = new Thread(); | 161 Thread* thread = new Thread(); |
162 // Verify that current thread was set. | 162 // Verify that current thread was set. |
163 ASSERT(Thread::Current() == thread); | 163 ASSERT(Thread::Current() == thread); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 | 167 |
168 #if defined(TARGET_OS_WINDOWS) | |
169 void Thread::CleanUp() { | |
170 Thread* current = Current(); | |
171 if (current != NULL) { | |
172 SetCurrent(NULL); | |
173 delete current; | |
174 } | |
175 } | |
176 #endif | |
177 | |
178 #if defined(DEBUG) | 168 #if defined(DEBUG) |
179 #define REUSABLE_HANDLE_SCOPE_INIT(object) \ | 169 #define REUSABLE_HANDLE_SCOPE_INIT(object) \ |
180 reusable_##object##_handle_scope_active_(false), | 170 reusable_##object##_handle_scope_active_(false), |
181 #else | 171 #else |
182 #define REUSABLE_HANDLE_SCOPE_INIT(object) | 172 #define REUSABLE_HANDLE_SCOPE_INIT(object) |
183 #endif // defined(DEBUG) | 173 #endif // defined(DEBUG) |
184 | 174 |
185 #define REUSABLE_HANDLE_INITIALIZERS(object) \ | 175 #define REUSABLE_HANDLE_INITIALIZERS(object) \ |
186 object##_handle_(NULL), | 176 object##_handle_(NULL), |
187 | 177 |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 | 520 |
531 | 521 |
532 Thread* ThreadIterator::Next() { | 522 Thread* ThreadIterator::Next() { |
533 ASSERT(Thread::thread_list_lock_ != NULL); | 523 ASSERT(Thread::thread_list_lock_ != NULL); |
534 ASSERT(Thread::thread_list_lock_->IsOwnedByCurrentThread()); | 524 ASSERT(Thread::thread_list_lock_->IsOwnedByCurrentThread()); |
535 Thread* current = next_; | 525 Thread* current = next_; |
536 next_ = next_->thread_list_next_; | 526 next_ = next_->thread_list_next_; |
537 return current; | 527 return current; |
538 } | 528 } |
539 | 529 |
540 #if defined(TARGET_OS_WINDOWS) | |
541 // This function is invoked by |OnThreadExit| found in os_thread_win.cc. | |
542 void ThreadCleanupOnExit() { | |
543 // Windows does not support TLS destructors (see os_thread_win.cc for | |
544 // context). As a work around, we maintain a list of functions to be | |
545 // executed when a thread exits in |OnThreadExit| in os_thread_win.cc. | |
546 Thread::CleanUp(); | |
547 } | |
548 #endif | |
549 | |
550 | 530 |
551 } // namespace dart | 531 } // namespace dart |
OLD | NEW |