| 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/json_stream.h" |
| 9 #include "vm/lockers.h" | 9 #include "vm/lockers.h" |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 JSONArray threads(stream); | 98 JSONArray threads(stream); |
| 99 Thread* current = active_list_; | 99 Thread* current = active_list_; |
| 100 while (current != NULL) { | 100 while (current != NULL) { |
| 101 threads.AddValue(current); | 101 threads.AddValue(current); |
| 102 current = current->next_; | 102 current = current->next_; |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 #endif | 105 #endif |
| 106 | 106 |
| 107 | 107 |
| 108 intptr_t ThreadRegistry::CountZoneHandles() const { |
| 109 MonitorLocker ml(threads_lock()); |
| 110 intptr_t count = 0; |
| 111 Thread* current = active_list_; |
| 112 while (current != NULL) { |
| 113 count += current->CountZoneHandles(); |
| 114 current = current->next_; |
| 115 } |
| 116 return count; |
| 117 } |
| 118 |
| 119 |
| 120 intptr_t ThreadRegistry::CountScopedHandles() const { |
| 121 MonitorLocker ml(threads_lock()); |
| 122 intptr_t count = 0; |
| 123 Thread* current = active_list_; |
| 124 while (current != NULL) { |
| 125 count += current->CountScopedHandles(); |
| 126 current = current->next_; |
| 127 } |
| 128 return count; |
| 129 } |
| 130 |
| 131 |
| 108 void ThreadRegistry::AddToActiveListLocked(Thread* thread) { | 132 void ThreadRegistry::AddToActiveListLocked(Thread* thread) { |
| 109 ASSERT(thread != NULL); | 133 ASSERT(thread != NULL); |
| 110 ASSERT(threads_lock()->IsOwnedByCurrentThread()); | 134 ASSERT(threads_lock()->IsOwnedByCurrentThread()); |
| 111 thread->next_ = active_list_; | 135 thread->next_ = active_list_; |
| 112 active_list_ = thread; | 136 active_list_ = thread; |
| 113 } | 137 } |
| 114 | 138 |
| 115 | 139 |
| 116 void ThreadRegistry::RemoveFromActiveListLocked(Thread* thread) { | 140 void ThreadRegistry::RemoveFromActiveListLocked(Thread* thread) { |
| 117 ASSERT(thread != NULL); | 141 ASSERT(thread != NULL); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 ASSERT(thread->os_thread_ == NULL); | 175 ASSERT(thread->os_thread_ == NULL); |
| 152 ASSERT(thread->isolate_ == NULL); | 176 ASSERT(thread->isolate_ == NULL); |
| 153 ASSERT(thread->heap_ == NULL); | 177 ASSERT(thread->heap_ == NULL); |
| 154 ASSERT(threads_lock()->IsOwnedByCurrentThread()); | 178 ASSERT(threads_lock()->IsOwnedByCurrentThread()); |
| 155 // Add thread to the free list. | 179 // Add thread to the free list. |
| 156 thread->next_ = free_list_; | 180 thread->next_ = free_list_; |
| 157 free_list_ = thread; | 181 free_list_ = thread; |
| 158 } | 182 } |
| 159 | 183 |
| 160 } // namespace dart | 184 } // namespace dart |
| OLD | NEW |