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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/isolate.cc » ('j') | runtime/lib/isolate.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef INCLUDE_DART_API_H_ 5 #ifndef INCLUDE_DART_API_H_
6 #define INCLUDE_DART_API_H_ 6 #define INCLUDE_DART_API_H_
7 7
8 #ifdef __cplusplus 8 #ifdef __cplusplus
9 #define DART_EXTERN_C extern "C" 9 #define DART_EXTERN_C extern "C"
10 #else 10 #else
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 typedef enum { 72 typedef enum {
73 kLibraryTag = 0, 73 kLibraryTag = 0,
74 kImportTag, 74 kImportTag,
75 kSourceTag, 75 kSourceTag,
76 kCanonicalizeUrl, 76 kCanonicalizeUrl,
77 } Dart_LibraryTag; 77 } Dart_LibraryTag;
78 78
79 typedef void Dart_Snapshot; 79 typedef void Dart_Snapshot;
80 80
81 typedef int64_t Dart_Port; 81 typedef int64_t Dart_Port;
82 typedef void* Dart_Message;
82 83
83 // Allow the embedder to intercept isolate creation. Both at startup and when 84 // Allow the embedder to intercept isolate creation. Both at startup
84 // spawning new isolates from Dart code. 85 // and when spawning new isolates from Dart code. The result returned
85 // The result returned from this callback is handed to all isolates spawned 86 // from this callback is handed to all isolates spawned from the
86 // from the isolate currently being initialized. 87 // isolate currently being initialized.
87 // Return NULL if an error is encountered. The isolate being initialized will 88 //
88 // be shutdown. No Dart code will execute in before it is shutdown. 89 // Return NULL if an error is encountered. The isolate being
90 // initialized will be shutdown. No Dart code will execute before it
91 // is shutdown.
92 //
89 // TODO(iposva): Pass a specification of the app file being spawned. 93 // TODO(iposva): Pass a specification of the app file being spawned.
90 typedef void* (*Dart_IsolateInitCallback)(void* data); 94 typedef void* (*Dart_IsolateInitCallback)(void* data);
91 95
92 typedef void (*Dart_NativeFunction)(Dart_NativeArguments arguments); 96 typedef void (*Dart_NativeFunction)(Dart_NativeArguments arguments);
93 typedef Dart_NativeFunction (*Dart_NativeEntryResolver)(Dart_Handle name, 97 typedef Dart_NativeFunction (*Dart_NativeEntryResolver)(Dart_Handle name,
94 int num_of_arguments); 98 int num_of_arguments);
95 typedef Dart_Result (*Dart_LibraryTagHandler)(Dart_LibraryTag tag, 99 typedef Dart_Result (*Dart_LibraryTagHandler)(Dart_LibraryTag tag,
96 Dart_Handle library, 100 Dart_Handle library,
97 Dart_Handle url); 101 Dart_Handle url);
98 102
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 187
184 // Isolate handling. 188 // Isolate handling.
185 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot, 189 DART_EXPORT Dart_Isolate Dart_CreateIsolate(const Dart_Snapshot* snapshot,
186 void* data); 190 void* data);
187 DART_EXPORT void Dart_ShutdownIsolate(); 191 DART_EXPORT void Dart_ShutdownIsolate();
188 192
189 DART_EXPORT Dart_Isolate Dart_CurrentIsolate(); 193 DART_EXPORT Dart_Isolate Dart_CurrentIsolate();
190 DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate); 194 DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate);
191 DART_EXPORT void Dart_ExitIsolate(); 195 DART_EXPORT void Dart_ExitIsolate();
192 196
197 // A convenience routine which processes any incoming messages for the
198 // current isolate. The routine exits when all ports to the current
199 // isolate are closed.
200 //
201 // This routine may only be used when the embedder has not provided an
202 // alternate message delivery mechanism with Dart_SetPostMessageCallback.
193 DART_EXPORT Dart_Result Dart_RunLoop(); 203 DART_EXPORT Dart_Result Dart_RunLoop();
194 204
205 // Messages/ports
Anton Muhin 2011/10/18 17:19:58 nit: missing trailing dot I believe.
turnidge 2011/10/18 17:33:40 This comment is intended as a title for the sectio
206
207 // A post message callback allows the embedder to provide an alternate
Anton Muhin 2011/10/18 17:19:58 nit: alternate -> alternative ?
turnidge 2011/10/18 17:33:40 Done.
208 // delivery mechanism for inter-isolate messages. It is the
209 // responsibility of the embedder to call Dart_HandleMessage to
210 // process the message.
211 //
212 // If there is no reply port, then the constant 'kNoReplyPort' is
213 // passed as the reply_port parameter.
Anton Muhin 2011/10/18 17:19:58 nit: reply_port -> 'reply_port' ?
turnidge 2011/10/18 17:33:40 Done.
214 //
215 // The memory pointed to by 'message' has been allocated by malloc. It
216 // is the responsibility of the callback to ensure that free(message)
Anton Muhin 2011/10/18 17:19:58 hmm, you're saying "Claims ownership of the memory
turnidge 2011/10/18 17:33:40 Nope. PortMap::PostMessage claims ownership from
217 // is called once the message has been processed.
218 //
219 // TODO(turnidge): Add a Dart_ReleaseMessage to hide allocation details?
220 typedef bool (*Dart_PostMessageCallback)(Dart_Isolate dest_isolate,
Anton Muhin 2011/10/18 17:19:58 what's the semantics of returned value?
turnidge 2011/10/18 17:33:40 Added: // The callback should return true if the
Anton Muhin 2011/10/18 17:40:54 Great. Minor correction: not posted, but somethin
221 Dart_Port dest_port,
222 Dart_Port reply_port,
223 Dart_Message message);
224 const Dart_Port kNoReplyPort = 0;
225
226 // A close port callback allows the embedder to receive notification
227 // when a port is closed. The constant 'kCloseAllPorts' is passed as
228 // the 'port' parameter when all active ports are being closed at
229 // once.
230 typedef void (*Dart_ClosePortCallback)(Dart_Isolate isolate,
231 Dart_Port port);
232 const Dart_Port kCloseAllPorts = 0;
233
234 // Allows embedders to provide an alternate mechanism for sending
235 // inter-isolate messages. This setting only applies to the current
236 // isolate.
237 //
238 // Most embedders will only call this function once, before isolate
239 // execution begins. If this function is called after isolate
240 // execution begins, the embedder is responsible for threading issues.
241 DART_EXPORT void Dart_SetMessageCallbacks(
242 Dart_PostMessageCallback post_message_callback,
243 Dart_ClosePortCallback close_port_callback);
244
245 // Handle a message on the current isolate.
246 DART_EXPORT void Dart_HandleMessage(Dart_Port dest_port,
247 Dart_Port reply_port,
248 Dart_Message dart_message);
249
195 250
196 // Object. 251 // Object.
197 DART_EXPORT Dart_Result Dart_ObjectToString(Dart_Handle object); 252 DART_EXPORT Dart_Result Dart_ObjectToString(Dart_Handle object);
198 DART_EXPORT bool Dart_IsNull(Dart_Handle object); 253 DART_EXPORT bool Dart_IsNull(Dart_Handle object);
199 254
200 255
201 // Returns true if the two objects are equal. 256 // Returns true if the two objects are equal.
202 DART_EXPORT Dart_Result Dart_Objects_Equal(Dart_Handle obj1, Dart_Handle obj2); 257 DART_EXPORT Dart_Result Dart_Objects_Equal(Dart_Handle obj1, Dart_Handle obj2);
203 258
204 259
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 // External pprof support for gathering and dumping symbolic information 441 // External pprof support for gathering and dumping symbolic information
387 // that can be used for better profile reports for dynamically generated 442 // that can be used for better profile reports for dynamically generated
388 // code. 443 // code.
389 DART_EXPORT void Dart_InitPprofSupport(); 444 DART_EXPORT void Dart_InitPprofSupport();
390 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); 445 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size);
391 446
392 // Check set vm flags. 447 // Check set vm flags.
393 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name); 448 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name);
394 449
395 #endif // INCLUDE_DART_API_H_ 450 #endif // INCLUDE_DART_API_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/isolate.cc » ('j') | runtime/lib/isolate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698