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

Unified Diff: runtime/vm/isolate.h

Issue 1260283007: Fix race and limit access to mutator_thread_. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove debug print. 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 | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate.h
diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h
index 43031c4c19a56153c695e5dfe05a1778ab2db468..c43a3fa7f5fa6c3075a8c8ec8e0bb5f50d77d6b2 100644
--- a/runtime/vm/isolate.h
+++ b/runtime/vm/isolate.h
@@ -157,16 +157,15 @@ class Isolate : public BaseIsolate {
message_notify_callback_ = value;
}
- // A thread that operates on this isolate and may execute Dart code.
- // No other threads operating on this isolate may execute Dart code.
- // TODO(koda): Remove after pivoting to thread in NativeArguments.
- Thread* mutator_thread() {
- DEBUG_ASSERT(mutator_thread_ == NULL || IsIsolateOf(mutator_thread_));
- return mutator_thread_;
+ // Limited public access to BaseIsolate::mutator_thread_ for code that
+ // must treat the mutator as the default or a special case. Prefer code
+ // that works uniformly across all threads.
+ bool HasMutatorThread() {
+ return mutator_thread_ != NULL;
+ }
+ bool MutatorThreadIsCurrentThread() {
+ return mutator_thread_ == Thread::Current();
}
-#if defined(DEBUG)
- bool IsIsolateOf(Thread* thread);
-#endif // DEBUG
const char* name() const { return name_; }
const char* debugger_name() const { return debugger_name_; }
@@ -774,9 +773,17 @@ class Isolate : public BaseIsolate {
user_tag_ = tag;
}
- void set_mutator_thread(Thread* thread) {
+ void ClearMutatorThread() {
+ mutator_thread_ = NULL;
+ }
+ void MakeCurrentThreadMutator(Thread* thread) {
+ ASSERT(thread == Thread::Current());
+ DEBUG_ASSERT(IsIsolateOf(thread));
mutator_thread_ = thread;
}
+#if defined(DEBUG)
+ bool IsIsolateOf(Thread* thread);
+#endif // DEBUG
template<class T> T* AllocateReusableHandle();
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698