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

Unified Diff: runtime/include/dart_api.h

Issue 8297004: Allow embedders to provide custom message delivery for an isolate. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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') | runtime/vm/dart_api_impl.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/include/dart_api.h
===================================================================
--- runtime/include/dart_api.h (revision 460)
+++ runtime/include/dart_api.h (working copy)
@@ -79,13 +79,17 @@
typedef void Dart_Snapshot;
typedef int64_t Dart_Port;
+typedef void* Dart_Message;
-// Allow the embedder to intercept isolate creation. Both at startup and when
-// spawning new isolates from Dart code.
-// The result returned from this callback is handed to all isolates spawned
-// from the isolate currently being initialized.
-// Return NULL if an error is encountered. The isolate being initialized will
-// be shutdown. No Dart code will execute in before it is shutdown.
+// Allow the embedder to intercept isolate creation. Both at startup
+// and when spawning new isolates from Dart code. The result returned
+// from this callback is handed to all isolates spawned from the
+// isolate currently being initialized.
+//
+// Return NULL if an error is encountered. The isolate being
+// initialized will be shutdown. No Dart code will execute before it
+// is shutdown.
+//
// TODO(iposva): Pass a specification of the app file being spawned.
typedef void* (*Dart_IsolateInitCallback)(void* data);
@@ -190,9 +194,51 @@
DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate);
DART_EXPORT void Dart_ExitIsolate();
+// A convenience routine for which processes any incoming messages for
siva 2011/10/14 23:50:32 routine which
turnidge 2011/10/17 18:38:48 Done.
Anton Muhin 2011/10/18 07:01:03 I think Siva meant "A convenience routine which pr
turnidge 2011/10/18 16:42:14 Yeah, forgot to upload, sorry. On 2011/10/18 07:0
+// the current isolate. The routine exits when all ports to the
+// current isolate are closed
siva 2011/10/14 23:50:32 closed.
turnidge 2011/10/17 18:38:48 Done.
Anton Muhin 2011/10/18 07:01:03 Nit, missing trailing dot. On 2011/10/17 18:38:48
turnidge 2011/10/18 16:42:14 Ditto upload. On 2011/10/18 07:01:03, antonmuhin
+//
+// This routine may only be used when the embedder has not provided an
+// alternate message delivery mechanism with Dart_SetPostMessageCallback.
DART_EXPORT Dart_Result Dart_RunLoop();
+// Messages/ports
+// A post message callback allows the embedder to provide an alternate
+// delivery mechanism for inter-isolate messages. The callback must
Anton Muhin 2011/10/17 15:20:29 is it indeed a must? May I just drop some message
turnidge 2011/10/17 18:38:48 I suppose it isn't a must, if you don't care about
Anton Muhin 2011/10/18 07:01:03 I like your new wording, thanks a lot. On 2011/10
+// eventually cause Dart_HandleMessage to be called to process the
+// message.
+//
+// The memory pointed to by 'message' has been allocated by malloc. It
+// is the responsibility of the callback to ensure that free(message)
Anton Muhin 2011/10/18 07:01:03 that somewhat leaks the abstraction---we have this
turnidge 2011/10/18 16:42:14 I agree that this leaks the abstraction. I've add
+// is called once the message has been processed.
+typedef bool (*Dart_PostMessageCallback)(Dart_Isolate dest_isolate,
+ Dart_Port dest_port,
+ Dart_Port reply_port,
+ Dart_Message message);
+
+// Allow embedders to provide an alternate delivery mechanism for
Anton Muhin 2011/10/17 15:20:29 nit: it looks like 3rd person is preferred: allow[
turnidge 2011/10/17 18:38:48 Done.
+// inter-isolate messages. This setting only applies to the current
+// isolate.
+DART_EXPORT void Dart_SetPostMessageCallback(Dart_PostMessageCallback callback);
Anton Muhin 2011/10/17 15:20:29 is _SetPostMessageCallback thread safe? Imagine m
turnidge 2011/10/17 18:38:48 Added some documentation around this. I also comb
+
+// A close port callback allows the embedder to receive notification
+// when a port is closed. The constant 'kCloseAllPorts' is passed
Anton Muhin 2011/10/17 15:20:29 nit: in port parameter?
turnidge 2011/10/17 18:38:48 Done.
+// when all active ports are being closed at once.
+typedef void (*Dart_ClosePortCallback)(Dart_Isolate isolate,
+ Dart_Port port);
+const Dart_Port kCloseAllPorts = 0;
+
+// Allow embedder to receive notification when a port is closed. This
+// setting only applies to the current isolate.
+DART_EXPORT void Dart_SetClosePortCallback(Dart_ClosePortCallback callback);
+
+// Handle a message on the current isolate.
+DART_EXPORT void Dart_HandleMessage(Dart_Port dest_port,
Anton Muhin 2011/10/17 15:20:29 do we need to pass ports around? maybe we can bun
turnidge 2011/10/17 18:38:48 They are sort of useless for the default, standalo
+ Dart_Port reply_port,
+ Dart_Message dart_message);
+
+
// Object.
DART_EXPORT Dart_Result Dart_ObjectToString(Dart_Handle object);
DART_EXPORT bool Dart_IsNull(Dart_Handle object);
« no previous file with comments | « no previous file | runtime/lib/isolate.cc » ('j') | runtime/vm/dart_api_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698