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

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, 8 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/vm/native_message_handler.h ('k') | runtime/vm/port.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/native_message_handler.cc
===================================================================
--- runtime/vm/native_message_handler.cc (revision 6698)
+++ runtime/vm/native_message_handler.cc (working copy)
@@ -41,47 +41,24 @@
}
-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->IsOOB()) {
+ // We currently do not use OOB messages for native ports.
+ UNREACHABLE();
}
-}
+ // 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
« no previous file with comments | « runtime/vm/native_message_handler.h ('k') | runtime/vm/port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698