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

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') | no next file with comments »
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
206
207 // A post message callback allows the embedder to provide an alternate
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.
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)
217 // is called once the message has been processed.
218 //
219 // The callback should return false if it runs into a problem
220 // processing this message.
221 //
222 // Todo(turnidge): Add a Dart_ReleaseMessage to hide allocation details?
223 typedef bool (*Dart_PostMessageCallback)(Dart_Isolate dest_isolate,
224 Dart_Port dest_port,
225 Dart_Port reply_port,
226 Dart_Message message);
227 const Dart_Port kNoReplyPort = 0;
228
229 // A close port callback allows the embedder to receive notification
230 // when a port is closed. The constant 'kCloseAllPorts' is passed as
231 // the 'port' parameter when all active ports are being closed at
232 // once.
233 typedef void (*Dart_ClosePortCallback)(Dart_Isolate isolate,
234 Dart_Port port);
235 const Dart_Port kCloseAllPorts = 0;
236
237 // Allows embedders to provide an alternative mechanism for sending
238 // inter-isolate messages. This setting only applies to the current
239 // isolate.
240 //
241 // Most embedders will only call this function once, before isolate
242 // execution begins. If this function is called after isolate
243 // execution begins, the embedder is responsible for threading issues.
244 //
245 // TODO(turnidge): Consider moving this to isolate creation so that it
246 // is impossible to mess up.
247 DART_EXPORT void Dart_SetMessageCallbacks(
248 Dart_PostMessageCallback post_message_callback,
249 Dart_ClosePortCallback close_port_callback);
250
251 // Handle a message on the current isolate.
252 DART_EXPORT void Dart_HandleMessage(Dart_Port dest_port,
253 Dart_Port reply_port,
254 Dart_Message dart_message);
255
195 256
196 // Object. 257 // Object.
197 DART_EXPORT Dart_Result Dart_ObjectToString(Dart_Handle object); 258 DART_EXPORT Dart_Result Dart_ObjectToString(Dart_Handle object);
198 DART_EXPORT bool Dart_IsNull(Dart_Handle object); 259 DART_EXPORT bool Dart_IsNull(Dart_Handle object);
199 260
200 261
201 // Returns true if the two objects are equal. 262 // Returns true if the two objects are equal.
202 DART_EXPORT Dart_Result Dart_Objects_Equal(Dart_Handle obj1, Dart_Handle obj2); 263 DART_EXPORT Dart_Result Dart_Objects_Equal(Dart_Handle obj1, Dart_Handle obj2);
203 264
204 265
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 // External pprof support for gathering and dumping symbolic information 447 // External pprof support for gathering and dumping symbolic information
387 // that can be used for better profile reports for dynamically generated 448 // that can be used for better profile reports for dynamically generated
388 // code. 449 // code.
389 DART_EXPORT void Dart_InitPprofSupport(); 450 DART_EXPORT void Dart_InitPprofSupport();
390 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); 451 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size);
391 452
392 // Check set vm flags. 453 // Check set vm flags.
393 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name); 454 DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name);
394 455
395 #endif // INCLUDE_DART_API_H_ 456 #endif // INCLUDE_DART_API_H_
OLDNEW
« 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