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

Unified Diff: dart/runtime/bin/eventhandler.cc

Issue 875403006: Wait for eventhandler to shut down before exiting (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove call to EventHandler::Stop() since VM doesn't support clean shutdown yet Created 5 years, 10 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 | « dart/runtime/bin/eventhandler.h ('k') | dart/runtime/bin/eventhandler_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/runtime/bin/eventhandler.cc
diff --git a/dart/runtime/bin/eventhandler.cc b/dart/runtime/bin/eventhandler.cc
index 542602f6bde2bac4b8dec8c5393dd158d2acfec6..4d29d95a109a3da3cd768b104abcc9a57cb86d82 100644
--- a/dart/runtime/bin/eventhandler.cc
+++ b/dart/runtime/bin/eventhandler.cc
@@ -4,7 +4,9 @@
#include "bin/dartutils.h"
#include "bin/eventhandler.h"
+#include "bin/lockers.h"
#include "bin/socket.h"
+#include "bin/thread.h"
#include "include/dart_api.h"
@@ -57,19 +59,40 @@ void TimeoutQueue::UpdateTimeout(Dart_Port port, int64_t timeout) {
static EventHandler* event_handler = NULL;
+static Monitor *shutdown_monitor = NULL;
void EventHandler::Start() {
ASSERT(event_handler == NULL);
+ shutdown_monitor = new Monitor();
event_handler = new EventHandler();
event_handler->delegate_.Start(event_handler);
}
+void EventHandler::NotifyShutdownDone() {
+ MonitorLocker ml(shutdown_monitor);
+ ml.Notify();
+}
+
+
void EventHandler::Stop() {
if (event_handler == NULL) return;
- event_handler->delegate_.Shutdown();
+
+ // Wait until it has stopped.
+ {
+ MonitorLocker ml(shutdown_monitor);
+
+ // Signal to event handler that we want it to stop.
+ event_handler->delegate_.Shutdown();
+ ml.Wait(Monitor::kNoTimeout);
+ }
+
+ // Cleanup
+ delete event_handler;
event_handler = NULL;
+ delete shutdown_monitor;
+ shutdown_monitor = NULL;
}
« no previous file with comments | « dart/runtime/bin/eventhandler.h ('k') | dart/runtime/bin/eventhandler_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698