Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Unified Diff: runtime/vm/thread_registry.h

Issue 1271773003: Allow threads to exit an isolate during rendezvous. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Another assertion. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/thread_registry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/thread_registry.h
diff --git a/runtime/vm/thread_registry.h b/runtime/vm/thread_registry.h
index 94029f54fdeb0c0ca10a5378c47b8cb68aa2e34d..f8f324dc752a2215edfa592086b3d5fbcd1944d3 100644
--- a/runtime/vm/thread_registry.h
+++ b/runtime/vm/thread_registry.h
@@ -25,10 +25,12 @@ class ThreadRegistry {
// Bring all threads in this isolate to a safepoint. The caller is
// expected to be implicitly at a safepoint. The threads will wait
- // until ResumeAllThreads is called. Must be called at a safepoint,
- // since it first waits for any already pending requests. Any thread
- // that tries to enter/exit this isolate during rendezvous will wait
- // in RestoreStateTo/SaveStateFrom, respectively.
+ // until ResumeAllThreads is called. First participates in any
+ // already pending rendezvous requested by another thread. Any
+ // thread that tries to enter this isolate during rendezvous will
+ // wait in RestoreStateTo. Nesting is not supported: the caller must
+ // call ResumeAllThreads before making further calls to
+ // SafepointThreads.
void SafepointThreads();
// Unblocks all threads participating in the rendezvous that was organized
@@ -80,13 +82,18 @@ class ThreadRegistry {
void SaveStateFrom(Thread* thread, const Thread::State& state) {
MonitorLocker ml(monitor_);
- // Exiting an isolate must always be a safepoint.
- CheckSafepointLocked();
Entry* entry = FindEntry(thread);
ASSERT(entry != NULL);
ASSERT(entry->scheduled);
entry->scheduled = false;
entry->state = state;
+ if (in_rendezvous_) {
+ // Don't wait for this thread.
+ ASSERT(remaining_ > 0);
+ if (--remaining_ == 0) {
+ ml.NotifyAll();
+ }
+ }
}
bool Contains(Thread* thread) {
« no previous file with comments | « no previous file | runtime/vm/thread_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698