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

Unified Diff: runtime/bin/eventhandler.cc

Issue 22901017: Always initialize the EventHandler in the standalone. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
Index: runtime/bin/eventhandler.cc
diff --git a/runtime/bin/eventhandler.cc b/runtime/bin/eventhandler.cc
index a07cf3d4192d753d472eb4e605f228110ec211a9..4cfd089d06a59cbf75581f66eb91890eacaf04e2 100644
--- a/runtime/bin/eventhandler.cc
+++ b/runtime/bin/eventhandler.cc
@@ -63,23 +63,22 @@ void TimeoutQueue::UpdateTimeout(Dart_Port port, int64_t timeout) {
}
-void EventHandler::Stop() {
+/*
+ * Starts the EventHandler thread.
+ */
+void EventHandler::Start() {
Søren Gjesse 2013/08/21 13:52:05 You don't need the mutex here any more.
Anders Johnsen 2013/08/22 11:31:05 Done.
MutexLocker locker(mutex_);
Søren Gjesse 2013/08/21 13:52:05 Assert that event_handler_ is NULL.
Anders Johnsen 2013/08/22 11:31:05 Done.
- if (event_handler == NULL) return;
- event_handler->Shutdown();
- event_handler = NULL;
+ if (event_handler != NULL) return;
+ event_handler = new EventHandler();
Søren Gjesse 2013/08/21 13:52:05 If we want we can still postpone the actual start
Anders Johnsen 2013/08/22 11:31:05 Yes, but I would like to avoid the extra check on
+ event_handler->delegate_.Start(event_handler);
}
-/*
- * Starts the EventHandler thread and stores its reference in the dart
- * EventHandler object. args[0] holds the reference to the dart EventHandler
- * object.
- */
-void FUNCTION_NAME(EventHandler_Start)(Dart_NativeArguments args) {
+void EventHandler::Stop() {
MutexLocker locker(mutex_);
- if (event_handler != NULL) return;
- event_handler = EventHandler::Start();
+ if (event_handler == NULL) return;
+ event_handler->Shutdown();
+ event_handler = NULL;
}
@@ -89,17 +88,17 @@ void FUNCTION_NAME(EventHandler_Start)(Dart_NativeArguments args) {
* holds the reference to the dart EventHandler object.
*/
void FUNCTION_NAME(EventHandler_SendData)(Dart_NativeArguments args) {
- Dart_Handle sender = Dart_GetNativeArgument(args, 1);
+ Dart_Handle sender = Dart_GetNativeArgument(args, 0);
intptr_t id = kInvalidId;
if (Dart_IsNull(sender)) {
id = kTimerId;
} else {
Socket::GetSocketIdNativeField(sender, &id);
}
- Dart_Handle handle = Dart_GetNativeArgument(args, 2);
+ Dart_Handle handle = Dart_GetNativeArgument(args, 1);
Dart_Port dart_port =
DartUtils::GetIntegerField(handle, DartUtils::kIdFieldName);
- int64_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 3));
+ int64_t data = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
{
MutexLocker locker(mutex_);
// Only send if the event_handler is not NULL. This means that the handler

Powered by Google App Engine
This is Rietveld 408576698