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

Unified Diff: runtime/include/dart_api.h

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 | « no previous file | runtime/lib/isolate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/include/dart_api.h
===================================================================
--- runtime/include/dart_api.h (revision 3743)
+++ runtime/include/dart_api.h (working copy)
@@ -429,6 +429,12 @@
typedef int64_t Dart_Port;
/**
+ * kIllegalPort is a port number guaranteed never to be associated
+ * with a valid port.
+ */
+const Dart_Port kIllegalPort = 0;
+
+/**
* A message notification callback.
*
* This callback allows the embedder to provide an alternate wakeup
@@ -522,6 +528,46 @@
DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle object);
/**
+ * A native message handler.
+ *
+ * This handler is associated with a native port by calling
+ * Dart_NewNativePort.
+ */
+typedef void (*Dart_NativeMessageHandler)(Dart_Port dest_port_id,
+ Dart_Port reply_port_id,
+ uint8_t* data);
+// TODO(turnidge): Make this function take more appropriate arguments.
+
+/**
+ * Creates a new native port. When messages are received on this
+ * native port, then they will be dispatched to the provided native
+ * message handler.
+ *
+ * \param name The name of this port in debugging messages.
+ * \param handler The C handler to run when messages arrive on the port.
+ * \param handle_concurrently Is it okay to process requests on this
+ * native port concurrently?
+ *
+ * \return If successful, returns the port id for the native port. In
+ * case of error, returns kIllegalPort.
+ */
+DART_EXPORT Dart_Port Dart_NewNativePort(const char* name,
+ Dart_NativeMessageHandler handler,
+ bool handle_concurrently);
+// TODO(turnidge): Currently handle_concurrently is ignored.
+
+/**
+ * Closes the native port with the given id.
+ *
+ * The port must have been allocated by a call to Dart_NewNativePort.
+ *
+ * \param native_port_id The id of the native port to close.
+ *
+ * \return Returns true if the port was closed successfully.
+ */
+DART_EXPORT bool Dart_CloseNativePort(Dart_Port native_port_id);
+
+/**
* Returns a new SendPort with the provided port id.
*/
DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id);
« no previous file with comments | « no previous file | runtime/lib/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698