OLD | NEW |
---|---|
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 /** \mainpage Dart Embedding API Reference | 8 /** \mainpage Dart Embedding API Reference |
9 * | 9 * |
10 * Dart is a class-based programming language for creating structured | 10 * Dart is a class-based programming language for creating structured |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
414 * 'isolate' as the current isolate (see | 414 * 'isolate' as the current isolate (see |
415 * Dart_IsolateInterruptCallback). | 415 * Dart_IsolateInterruptCallback). |
416 * | 416 * |
417 * \param isolate The isolate to be interrupted. | 417 * \param isolate The isolate to be interrupted. |
418 */ | 418 */ |
419 DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate); | 419 DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate); |
420 | 420 |
421 // --- Messages and Ports --- | 421 // --- Messages and Ports --- |
422 | 422 |
423 /** | 423 /** |
424 * Messages are used to communicate between isolates. | |
425 */ | |
426 typedef struct _Dart_Message* Dart_Message; | |
427 | |
428 /** | |
429 * A port is used to send or receive inter-isolate messages | 424 * A port is used to send or receive inter-isolate messages |
430 */ | 425 */ |
431 typedef int64_t Dart_Port; | 426 typedef int64_t Dart_Port; |
432 | 427 |
433 const Dart_Port kNoReplyPort = 0; | 428 /** |
429 * A message notification callback. | |
430 * | |
431 * This callback allows the embedder to provide an alternate wakeup | |
432 * mechanism for the delivery of inter-isolate messages. It is the | |
433 * responsibility of the embedder to call Dart_HandleMessage to | |
434 * process the message. | |
435 */ | |
436 typedef void (*Dart_MessageNotifyCallback)(Dart_Isolate dest_isolate); | |
434 | 437 |
435 /** | 438 /** |
436 * A message posting callback. | 439 * Allows embedders to provide an alternative wakeup mechanism for the |
437 * | 440 * delivery of inter-isolate messages. This setting only applies to |
438 * This callback allows the embedder to provide an alternate delivery | 441 * the current isolate. |
439 * mechanism for inter-isolate messages. It is the responsibility of | |
440 * the embedder to call Dart_HandleMessage to process the message. | |
441 * | |
442 * If there is no reply port, then the constant 'kNoReplyPort' is | |
443 * passed as the 'reply_port' parameter. | |
444 * | |
445 * The memory pointed to by 'message' has been allocated by malloc. It | |
446 * is the responsibility of the callback to ensure that free(message) | |
447 * is called once the message has been processed. | |
448 * | |
449 * The callback should return false if it runs into a problem | |
450 * processing this message. | |
451 */ | |
452 typedef bool (*Dart_PostMessageCallback)(Dart_Isolate dest_isolate, | |
453 Dart_Port dest_port_id, | |
454 Dart_Port reply_port_id, | |
455 Dart_Message message); | |
456 // TODO(turnidge): Add a Dart_ReleaseMessage to hide allocation details. | |
457 | |
458 const Dart_Port kCloseAllPorts = 0; | |
459 | |
460 /** | |
461 * A close port callback. | |
462 * | |
463 * This callback allows the embedder to receive notification when a | |
464 * port is closed. The constant 'kCloseAllPorts' is passed as the | |
465 * 'port' parameter when all active ports are being closed at once. | |
466 */ | |
467 typedef void (*Dart_ClosePortCallback)(Dart_Isolate isolate, | |
468 Dart_Port port_id); | |
469 | |
470 /** | |
471 * Allows embedders to provide an alternative mechanism for sending | |
472 * inter-isolate messages. This setting only applies to the current | |
473 * isolate. | |
474 * | 442 * |
475 * Most embedders will only call this function once, before isolate | 443 * Most embedders will only call this function once, before isolate |
476 * execution begins. If this function is called after isolate | 444 * execution begins. If this function is called after isolate |
477 * execution begins, the embedder is responsible for threading issues. | 445 * execution begins, the embedder is responsible for threading issues. |
478 */ | 446 */ |
479 DART_EXPORT void Dart_SetMessageCallbacks( | 447 DART_EXPORT void Dart_SetMessageNotifyCallback( |
480 Dart_PostMessageCallback post_message_callback, | 448 Dart_MessageNotifyCallback message_notify_callback); |
481 Dart_ClosePortCallback close_port_callback); | |
482 // TODO(turnidge): Consider moving this to isolate creation so that it | 449 // TODO(turnidge): Consider moving this to isolate creation so that it |
483 // is impossible to mess up. | 450 // is impossible to mess up. |
484 | 451 |
485 /** | 452 /** |
486 * Handles a message on the current isolate. | 453 * Handles the next pending message for the current isolate. |
487 * | 454 * |
488 * May generate an unhandled exception error. | 455 * May generate an unhandled exception error. |
489 * | 456 * |
490 * Note that this function does not free the memory associated with | |
491 * 'dart_message'. | |
492 * | |
493 * \return A valid handle if no error occurs during the operation. | 457 * \return A valid handle if no error occurs during the operation. |
494 */ | 458 */ |
495 DART_EXPORT Dart_Handle Dart_HandleMessage(Dart_Port dest_port_id, | 459 DART_EXPORT Dart_Handle Dart_HandleMessage(); |
496 Dart_Port reply_port_id, | |
497 Dart_Message dart_message); | |
498 // TODO(turnidge): Revisit memory management of 'dart_message'. | |
499 | 460 |
500 /** | 461 /** |
501 * Processes any incoming messages for the current isolate. | 462 * Processes any incoming messages for the current isolate. |
502 * | 463 * |
503 * This function may only be used when the embedder has not provided | 464 * This function may only be used when the embedder has not provided |
504 * an alternate message delivery mechanism with | 465 * an alternate message delivery mechanism with |
505 * Dart_SetMessageCallbacks. It is provided for convenience. | 466 * Dart_SetMessageCallbacks. It is provided for convenience. |
506 * | 467 * |
507 * This function waits for incoming messages for the current | 468 * This function waits for incoming messages for the current |
508 * isolate. As new messages arrive, they are handled using | 469 * isolate. As new messages arrive, they are handled using |
(...skipping 19 matching lines...) Expand all Loading... | |
528 */ | 489 */ |
529 DART_EXPORT bool Dart_HasLivePorts(); | 490 DART_EXPORT bool Dart_HasLivePorts(); |
530 | 491 |
531 /** | 492 /** |
532 * Posts a message for some isolate. The message is built from a raw | 493 * Posts a message for some isolate. The message is built from a raw |
533 * array. | 494 * array. |
534 * | 495 * |
535 * \param port The destination port. | 496 * \param port The destination port. |
536 * \param length The length of the data array. | 497 * \param length The length of the data array. |
537 * \param data A data array to be sent in the message. | 498 * \param data A data array to be sent in the message. |
538 * | |
539 * \return True if the message was posted. | |
540 */ | 499 */ |
541 DART_EXPORT bool Dart_PostIntArray(Dart_Port port_id, | 500 DART_EXPORT bool Dart_PostIntArray(Dart_Port port_id, |
542 intptr_t length, | 501 intptr_t length, |
543 intptr_t* data); | 502 intptr_t* data); |
544 // TODO(turnidge): Should this be intptr_t or some fixed length type? | 503 // TODO(turnidge): Should this be intptr_t or some fixed length type? |
545 // TODO(turnidge): Reverse length/data for consistency. | 504 // TODO(turnidge): Reverse length/data for consistency. |
546 | 505 |
547 /** | 506 /** |
548 * Posts a message for some isolate. The message is a serialized | 507 * Posts a message for some isolate. The message is a serialized |
549 * object. | 508 * object. |
550 * | 509 * |
551 * Requires there to be a current isolate. | 510 * Requires there to be a current isolate. |
552 * | 511 * |
553 * \param port The destination port. | 512 * \param port The destination port. |
554 * \param object An object from the current isolate. | 513 * \param object An object from the current isolate. |
555 * | |
556 * \return True if the message was posted. | |
Ivan Posva
2012/01/23 22:00:43
Why are you removing the documentation for these t
turnidge
2012/01/23 22:32:52
In an earlier rev, I made these void functions. T
| |
557 */ | 514 */ |
558 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle object); | 515 DART_EXPORT bool Dart_Post(Dart_Port port_id, Dart_Handle object); |
559 | 516 |
560 /** | 517 /** |
561 * Returns a new SendPort with the provided port id. | 518 * Returns a new SendPort with the provided port id. |
562 */ | 519 */ |
563 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id); | 520 DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id); |
564 | 521 |
565 /** | 522 /** |
566 * Gets the ReceivePort for the provided port id, creating it if necessary. | 523 * Gets the ReceivePort for the provided port id, creating it if necessary. |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1381 | 1338 |
1382 // --- Profiling support ---- | 1339 // --- Profiling support ---- |
1383 | 1340 |
1384 // External pprof support for gathering and dumping symbolic | 1341 // External pprof support for gathering and dumping symbolic |
1385 // information that can be used for better profile reports for | 1342 // information that can be used for better profile reports for |
1386 // dynamically generated code. | 1343 // dynamically generated code. |
1387 DART_EXPORT void Dart_InitPprofSupport(); | 1344 DART_EXPORT void Dart_InitPprofSupport(); |
1388 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); | 1345 DART_EXPORT void Dart_GetPprofSymbolInfo(void** buffer, int* buffer_size); |
1389 | 1346 |
1390 #endif // INCLUDE_DART_API_H_ | 1347 #endif // INCLUDE_DART_API_H_ |
OLD | NEW |