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

Unified Diff: runtime/bin/eventhandler_win.cc

Issue 10693039: Terminate event handler thread on isolate shutdown. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding new file to gyp file Created 8 years, 6 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/bin/eventhandler_win.h ('k') | runtime/bin/isolate_data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_win.cc
diff --git a/runtime/bin/eventhandler_win.cc b/runtime/bin/eventhandler_win.cc
index 53790592cd53a53cfccb531864fc87d2155f0efd..4917a089152f7cf9ac8f3424d6fa0a3e0d287f27 100644
--- a/runtime/bin/eventhandler_win.cc
+++ b/runtime/bin/eventhandler_win.cc
@@ -16,6 +16,8 @@
static const int kInfinityTimeout = -1;
+static const int kTimeoutId = -1;
+static const int kShutdownId = -2;
int64_t GetCurrentTimeMilliseconds() {
@@ -615,11 +617,13 @@ bool ClientSocket::IsClosed() {
void EventHandlerImplementation::HandleInterrupt(InterruptMessage* msg) {
- if (msg->id == -1) {
+ if (msg->id == kTimeoutId) {
// Change of timeout request. Just set the new timeout and port as the
// completion thread will use the new timeout value for its next wait.
timeout_ = msg->data;
timeout_port_ = msg->dart_port;
+ } else if (msg->id == kShutdownId) {
+ shutdown_ = true;
} else {
bool delete_handle = false;
Handle* handle = reinterpret_cast<Handle*>(msg->id);
@@ -827,6 +831,7 @@ EventHandlerImplementation::EventHandlerImplementation() {
}
timeout_ = kInfinityTimeout;
timeout_port_ = 0;
+ shutdown_ = false;
}
@@ -854,11 +859,11 @@ void EventHandlerImplementation::SendData(intptr_t id,
}
-static void EventHandlerThread(uword args) {
+void EventHandlerImplementation::EventHandlerEntry(uword args) {
EventHandlerImplementation* handler =
reinterpret_cast<EventHandlerImplementation*>(args);
ASSERT(handler != NULL);
- while (true) {
+ while (!handler->shutdown_) {
DWORD bytes;
ULONG_PTR key;
OVERLAPPED* overlapped;
@@ -906,8 +911,8 @@ static void EventHandlerThread(uword args) {
}
-void EventHandlerImplementation::StartEventHandler() {
- int result = dart::Thread::Start(EventHandlerThread,
+void EventHandlerImplementation::Start() {
+ int result = dart::Thread::Start(EventHandlerEntry,
reinterpret_cast<uword>(this));
if (result != 0) {
FATAL1("Failed to start event handler thread %d", result);
@@ -918,3 +923,8 @@ void EventHandlerImplementation::StartEventHandler() {
FATAL("Failed to initialized Windows sockets");
}
}
+
+
+void EventHandlerImplementation::Shutdown() {
+ SendData(kShutdownId, 0, 0);
+}
« no previous file with comments | « runtime/bin/eventhandler_win.h ('k') | runtime/bin/isolate_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698