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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 9169063: Add support for native ports in the vm. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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/dart_api_impl.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/dart_api_impl.cc
===================================================================
--- runtime/vm/dart_api_impl.cc (revision 3743)
+++ runtime/vm/dart_api_impl.cc (working copy)
@@ -15,8 +15,9 @@
#include "vm/exceptions.h"
#include "vm/growable_array.h"
#include "vm/longjump.h"
-#include "vm/message_queue.h"
+#include "vm/message.h"
#include "vm/native_entry.h"
+#include "vm/native_message_handler.h"
#include "vm/object.h"
#include "vm/object_store.h"
#include "vm/port.h"
@@ -676,7 +677,7 @@
Message::Priority priority = Message::kNormalPriority;
do {
DARTSCOPE(isolate);
- message = isolate->message_queue()->DequeueNoWait();
+ message = isolate->message_handler()->queue()->DequeueNoWait();
if (message == NULL) {
break;
}
@@ -705,7 +706,7 @@
DART_EXPORT bool Dart_HasLivePorts() {
Isolate* isolate = Isolate::Current();
ASSERT(isolate);
- return isolate->live_ports() > 0;
+ return isolate->message_handler()->HasLivePorts();
}
@@ -743,6 +744,37 @@
}
+DART_EXPORT Dart_Port Dart_NewNativePort(const char* name,
+ Dart_NativeMessageHandler handler,
+ bool handle_concurrently) {
+ if (name == NULL) {
+ name = "<UnnamedNativePort>";
+ }
+ if (handler == NULL) {
+ OS::PrintErr("%s expects argument 'handler' to be non-null.", CURRENT_FUNC);
+ return kIllegalPort;
+ }
+ // Start the native port without a current isolate.
+ IsolateSaver saver(Isolate::Current());
+ Isolate::SetCurrent(NULL);
+
+ NativeMessageHandler* nmh = new NativeMessageHandler(name, handler);
+ Dart_Port port_id = PortMap::CreatePort(nmh);
+ nmh->StartWorker();
+ return port_id;
+}
+
+
+DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id) {
+ // Close the native port without a current isolate.
+ IsolateSaver saver(Isolate::Current());
+ Isolate::SetCurrent(NULL);
+
+ // TODO(turnidge): Check that the port is native before trying to close.
+ return PortMap::ClosePort(native_port_id);
+}
+
+
DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) {
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
« no previous file with comments | « runtime/vm/dart_api_impl.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698