Chromium Code Reviews| 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_registry.h" | 5 #include "vm/thread_registry.h" |
| 6 | 6 |
| 7 #include "vm/isolate.h" | 7 #include "vm/isolate.h" |
| 8 #include "vm/json_stream.h" | |
| 8 #include "vm/lockers.h" | 9 #include "vm/lockers.h" |
| 9 | 10 |
| 10 namespace dart { | 11 namespace dart { |
| 11 | 12 |
| 12 ThreadRegistry::~ThreadRegistry() { | 13 ThreadRegistry::~ThreadRegistry() { |
| 13 // Go over the free thread list and delete the thread objects. | 14 // Go over the free thread list and delete the thread objects. |
| 14 { | 15 { |
| 15 MonitorLocker ml(threads_lock()); | 16 MonitorLocker ml(threads_lock()); |
| 16 // At this point the active list should be empty. | 17 // At this point the active list should be empty. |
| 17 ASSERT(active_list_ == NULL); | 18 ASSERT(active_list_ == NULL); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 void ThreadRegistry::PrepareForGC() { | 85 void ThreadRegistry::PrepareForGC() { |
| 85 MonitorLocker ml(threads_lock()); | 86 MonitorLocker ml(threads_lock()); |
| 86 Thread* thread = active_list_; | 87 Thread* thread = active_list_; |
| 87 while (thread != NULL) { | 88 while (thread != NULL) { |
| 88 thread->PrepareForGC(); | 89 thread->PrepareForGC(); |
| 89 thread = thread->next_; | 90 thread = thread->next_; |
| 90 } | 91 } |
| 91 } | 92 } |
| 92 | 93 |
| 93 | 94 |
| 95 #if defined(DEBUG) | |
|
zra
2016/12/08 18:54:13
ditto
bkonyi
2016/12/08 20:58:32
Done.
| |
| 96 void ThreadRegistry::PrintJSON(JSONStream* stream, bool ref) const { | |
| 97 MonitorLocker ml(threads_lock()); | |
| 98 JSONArray threads(stream); | |
| 99 PrintJSONHelper(&threads, active_list_); | |
| 100 PrintJSONHelper(&threads, free_list_); | |
| 101 } | |
| 102 | |
| 103 | |
| 104 void ThreadRegistry::PrintJSONHelper(JSONArray* array, Thread* thread) const { | |
| 105 while (thread != NULL) { | |
| 106 array->AddValue(thread); | |
| 107 thread = thread->next_; | |
| 108 } | |
| 109 } | |
| 110 #endif | |
| 111 | |
| 112 | |
| 94 void ThreadRegistry::AddToActiveListLocked(Thread* thread) { | 113 void ThreadRegistry::AddToActiveListLocked(Thread* thread) { |
| 95 ASSERT(thread != NULL); | 114 ASSERT(thread != NULL); |
| 96 ASSERT(threads_lock()->IsOwnedByCurrentThread()); | 115 ASSERT(threads_lock()->IsOwnedByCurrentThread()); |
| 97 thread->next_ = active_list_; | 116 thread->next_ = active_list_; |
| 98 active_list_ = thread; | 117 active_list_ = thread; |
| 99 } | 118 } |
| 100 | 119 |
| 101 | 120 |
| 102 void ThreadRegistry::RemoveFromActiveListLocked(Thread* thread) { | 121 void ThreadRegistry::RemoveFromActiveListLocked(Thread* thread) { |
| 103 ASSERT(thread != NULL); | 122 ASSERT(thread != NULL); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 ASSERT(thread->os_thread_ == NULL); | 156 ASSERT(thread->os_thread_ == NULL); |
| 138 ASSERT(thread->isolate_ == NULL); | 157 ASSERT(thread->isolate_ == NULL); |
| 139 ASSERT(thread->heap_ == NULL); | 158 ASSERT(thread->heap_ == NULL); |
| 140 ASSERT(threads_lock()->IsOwnedByCurrentThread()); | 159 ASSERT(threads_lock()->IsOwnedByCurrentThread()); |
| 141 // Add thread to the free list. | 160 // Add thread to the free list. |
| 142 thread->next_ = free_list_; | 161 thread->next_ = free_list_; |
| 143 free_list_ = thread; | 162 free_list_ = thread; |
| 144 } | 163 } |
| 145 | 164 |
| 146 } // namespace dart | 165 } // namespace dart |
| OLD | NEW |