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

Unified Diff: runtime/bin/eventhandler_macos.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_macos.h ('k') | runtime/bin/eventhandler_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/eventhandler_macos.cc
diff --git a/runtime/bin/eventhandler_macos.cc b/runtime/bin/eventhandler_macos.cc
index 4166ce05f160871ba0a3ffd7a3c483f1898eb6c2..22c80eceb5393114bff3a4be7bf80f0f7868049e 100644
--- a/runtime/bin/eventhandler_macos.cc
+++ b/runtime/bin/eventhandler_macos.cc
@@ -32,6 +32,7 @@ int64_t GetCurrentTimeMilliseconds() {
static const int kInterruptMessageSize = sizeof(InterruptMessage);
static const int kInfinityTimeout = -1;
static const int kTimerId = -1;
+static const int kShutdownId = -2;
bool SocketData::HasReadEvent() {
@@ -123,6 +124,7 @@ EventHandlerImplementation::EventHandlerImplementation()
FDUtils::SetNonBlocking(interrupt_fds_[0]);
timeout_ = kInfinityTimeout;
timeout_port_ = 0;
+ shutdown_ = false;
kqueue_fd_ = TEMP_FAILURE_RETRY(kqueue());
if (kqueue_fd_ == -1) {
@@ -205,6 +207,8 @@ void EventHandlerImplementation::HandleInterruptFd() {
if (msg.id == kTimerId) {
timeout_ = msg.data;
timeout_port_ = msg.dart_port;
+ } else if (msg.id == kShutdownId) {
+ shutdown_ = true;
} else {
SocketData* sd = GetSocketData(msg.id);
if ((msg.data & (1 << kShutdownReadCommand)) != 0) {
@@ -357,7 +361,7 @@ void EventHandlerImplementation::EventHandlerEntry(uword args) {
EventHandlerImplementation* handler =
reinterpret_cast<EventHandlerImplementation*>(args);
ASSERT(handler != NULL);
- while (1) {
+ while (!handler->shutdown_) {
intptr_t millis = handler->GetTimeout();
// NULL pointer timespec for infinite timeout.
ASSERT(kInfinityTimeout < 0);
@@ -384,7 +388,7 @@ void EventHandlerImplementation::EventHandlerEntry(uword args) {
}
-void EventHandlerImplementation::StartEventHandler() {
+void EventHandlerImplementation::Start() {
int result =
dart::Thread::Start(&EventHandlerImplementation::EventHandlerEntry,
reinterpret_cast<uword>(this));
@@ -394,6 +398,11 @@ void EventHandlerImplementation::StartEventHandler() {
}
+void EventHandlerImplementation::Shutdown() {
+ SendData(kShutdownId, 0, 0);
+}
+
+
void EventHandlerImplementation::SendData(intptr_t id,
Dart_Port dart_port,
intptr_t data) {
« no previous file with comments | « runtime/bin/eventhandler_macos.h ('k') | runtime/bin/eventhandler_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698