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

Unified Diff: runtime/vm/dart.cc

Issue 25674009: Add framework for Dart_Terminate which will cleanup stuff on exit. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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.h ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart.cc
===================================================================
--- runtime/vm/dart.cc (revision 28185)
+++ runtime/vm/dart.cc (working copy)
@@ -74,7 +74,6 @@
};
-// TODO(turnidge): We should add a corresponding Dart::Cleanup.
const char* Dart::InitOnce(Dart_IsolateCreateCallback create,
Dart_IsolateInterruptCallback interrupt,
Dart_IsolateUnhandledExceptionCallback unhandled,
@@ -144,6 +143,37 @@
}
+const char* Dart::Cleanup() {
+#if 0
+ // Ideally we should shutdown the VM isolate here, but the thread pool
+ // shutdown does not seem to ensure that all the threads have stopped
+ // execution before it terminates, this results in racing isolates.
+ if (vm_isolate_ == NULL) {
+ return "VM already terminated.";
+ }
+
+ ASSERT(Isolate::Current() == NULL);
+
+ delete thread_pool_;
+ thread_pool_ = NULL;
+
+ // Set the VM isolate as current isolate.
+ Isolate::SetCurrent(vm_isolate_);
+
+ // There is a planned and known asymmetry here: We exit one scope for the VM
+ // isolate to account for the scope that was entered in Dart_InitOnce.
+ Dart_ExitScope();
+
+ ShutdownIsolate();
+ vm_isolate_ = NULL;
+#endif
+
+ CodeObservers::DeleteAll();
+
+ return NULL;
+}
+
+
Isolate* Dart::CreateIsolate(const char* name_prefix) {
// Create a new isolate.
Isolate* isolate = Isolate::Init(name_prefix);
« no previous file with comments | « runtime/vm/dart.h ('k') | runtime/vm/dart_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698