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

Unified Diff: runtime/vm/native_message_handler.cc

Issue 9924015: Use the ThreadPool for all isolates and native ports. Previously, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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/vm/native_message_handler.cc
===================================================================
--- runtime/vm/native_message_handler.cc (revision 5987)
+++ runtime/vm/native_message_handler.cc (working copy)
@@ -41,47 +41,26 @@
}
-static void RunWorker(uword parameter) {
- NativeMessageHandler* handler =
- reinterpret_cast<NativeMessageHandler*>(parameter);
-#if defined(DEBUG)
- handler->CheckAccess();
-#endif
-
- while (handler->HasLivePorts()) {
- Message* message = handler->queue()->Dequeue(0);
- if (message != NULL) {
- if (message->priority() >= Message::kOOBPriority) {
- // TODO(turnidge): Out of band messages will not go through
- // the regular message handler. Instead they will be
- // dispatched to special vm code. Implement.
- UNIMPLEMENTED();
- }
- // Enter a native scope for handling the message. This will create a
- // zone for allocating the objects for decoding the message.
- ApiNativeScope scope;
-
- int32_t length = reinterpret_cast<int32_t*>(
- message->data())[Snapshot::kLengthIndex];
- ApiMessageReader reader(message->data() + Snapshot::kHeaderSize,
- length,
- zone_allocator);
- Dart_CObject* object = reader.ReadMessage();
- (*handler->func())(message->dest_port(),
- message->reply_port(),
- object);
- delete message;
- }
+bool NativeMessageHandler::HandleMessage(Message* message) {
+ if (message->priority() >= Message::kOOBPriority) {
+ // TODO(turnidge): Out of band messages will not go through
+ // the regular message handler. Instead they will be
+ // dispatched to special vm code. Implement.
+ UNIMPLEMENTED();
Ivan Posva 2012/04/08 22:58:27 Should OOB messages be accepted by the native mess
turnidge 2012/04/11 19:37:16 With the current setup, HandleMessage is virtual,
turnidge 2012/04/17 23:46:55 Thought about this some more. Changed the comment
}
-}
+ // Enter a native scope for handling the message. This will create a
+ // zone for allocating the objects for decoding the message.
+ ApiNativeScope scope;
-
-void NativeMessageHandler::StartWorker() {
- int result = Thread::Start(RunWorker, reinterpret_cast<uword>(this));
- if (result != 0) {
- FATAL1("Failed to start native message handler worker thread %d", result);
- }
+ int32_t length = reinterpret_cast<int32_t*>(
+ message->data())[Snapshot::kLengthIndex];
+ ApiMessageReader reader(message->data() + Snapshot::kHeaderSize,
+ length,
+ zone_allocator);
+ Dart_CObject* object = reader.ReadMessage();
+ (*func())(message->dest_port(), message->reply_port(), object);
+ delete message;
+ return true;
}
-
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698