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 #ifndef VM_THREAD_REGISTRY_H_ | 5 #ifndef VM_THREAD_REGISTRY_H_ |
6 #define VM_THREAD_REGISTRY_H_ | 6 #define VM_THREAD_REGISTRY_H_ |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 // TODO(koda): Consider adding a scope helper to avoid omitting this call. | 41 // TODO(koda): Consider adding a scope helper to avoid omitting this call. |
42 void ResumeAllThreads(); | 42 void ResumeAllThreads(); |
43 | 43 |
44 // Indicate that the current thread is at a safepoint, and offer to wait for | 44 // Indicate that the current thread is at a safepoint, and offer to wait for |
45 // any pending rendezvous request (if none, returns immediately). | 45 // any pending rendezvous request (if none, returns immediately). |
46 void CheckSafepoint() { | 46 void CheckSafepoint() { |
47 MonitorLocker ml(monitor_); | 47 MonitorLocker ml(monitor_); |
48 CheckSafepointLocked(); | 48 CheckSafepointLocked(); |
49 } | 49 } |
50 | 50 |
| 51 bool AtSafepoint() const { return in_rendezvous_; } |
| 52 |
51 bool RestoreStateTo(Thread* thread, Thread::State* state, | 53 bool RestoreStateTo(Thread* thread, Thread::State* state, |
52 bool bypass_safepoint) { | 54 bool bypass_safepoint) { |
53 MonitorLocker ml(monitor_); | 55 MonitorLocker ml(monitor_); |
54 // Wait for any rendezvous in progress. | 56 // Wait for any rendezvous in progress. |
55 while (!bypass_safepoint && in_rendezvous_) { | 57 while (!bypass_safepoint && in_rendezvous_) { |
56 ml.Wait(Monitor::kNoTimeout); | 58 ml.Wait(Monitor::kNoTimeout); |
57 } | 59 } |
58 Entry* entry = FindEntry(thread); | 60 Entry* entry = FindEntry(thread); |
59 if (entry != NULL) { | 61 if (entry != NULL) { |
60 Thread::State st = entry->state; | 62 Thread::State st = entry->state; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 intptr_t remaining_; // Number of threads yet to reach their safepoint. | 205 intptr_t remaining_; // Number of threads yet to reach their safepoint. |
204 int64_t round_; // Counter, to prevent missing updates to remaining_ | 206 int64_t round_; // Counter, to prevent missing updates to remaining_ |
205 // (see comments in CheckSafepointLocked). | 207 // (see comments in CheckSafepointLocked). |
206 | 208 |
207 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry); | 209 DISALLOW_COPY_AND_ASSIGN(ThreadRegistry); |
208 }; | 210 }; |
209 | 211 |
210 } // namespace dart | 212 } // namespace dart |
211 | 213 |
212 #endif // VM_THREAD_REGISTRY_H_ | 214 #endif // VM_THREAD_REGISTRY_H_ |
OLD | NEW |