| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 * Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 3 * for details. All rights reserved. Use of this source code is governed by a | 3 * for details. All rights reserved. Use of this source code is governed by a |
| 4 * BSD-style license that can be found in the LICENSE file. | 4 * BSD-style license that can be found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #ifndef INCLUDE_DART_API_H_ | 7 #ifndef INCLUDE_DART_API_H_ |
| 8 #define INCLUDE_DART_API_H_ | 8 #define INCLUDE_DART_API_H_ |
| 9 | 9 |
| 10 /** \mainpage Dart Embedding API Reference | 10 /** \mainpage Dart Embedding API Reference |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #else | 58 #else |
| 59 #define DART_EXPORT DART_EXTERN_C | 59 #define DART_EXPORT DART_EXTERN_C |
| 60 #endif | 60 #endif |
| 61 #else | 61 #else |
| 62 #error Tool chain not supported. | 62 #error Tool chain not supported. |
| 63 #endif | 63 #endif |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 #include <assert.h> | 66 #include <assert.h> |
| 67 | 67 |
| 68 |
| 69 /* |
| 70 * ======== |
| 71 * Isolates |
| 72 * ======== |
| 73 */ |
| 74 |
| 75 /** |
| 76 * A port is used to send or receive inter-isolate messages. It is also used |
| 77 * to identify an isolate (see Dart_Isolate). |
| 78 */ |
| 79 typedef int64_t Dart_Port; |
| 80 |
| 81 |
| 82 /** |
| 83 * An isolate is the unit of concurrency in Dart. Each isolate has |
| 84 * its own memory and thread of control. No state is shared between |
| 85 * isolates. Instead, isolates communicate by message passing. |
| 86 * |
| 87 * Each thread keeps track of its current isolate, which is the |
| 88 * isolate which is ready to execute on the current thread. The |
| 89 * current isolate may be DART_ILLEGAL_ISOLATE, in which case no isolate is |
| 90 * ready to execute. Most of the Dart apis require there to be a current |
| 91 * isolate in order to function without error. The current isolate is |
| 92 * set by any call to Dart_CreateIsolate or Dart_EnterIsolate. |
| 93 */ |
| 94 typedef Dart_Port Dart_Isolate; |
| 95 |
| 96 /** |
| 97 * DART_ILLEGAL_ISOLATE is an isolate id that is guaranteed never to be associa
ted |
| 98 * with a valid isolate. |
| 99 */ |
| 100 #define DART_ILLEGAL_ISOLATE ((Dart_Isolate) 0) |
| 101 |
| 68 /* | 102 /* |
| 69 * ======= | 103 * ======= |
| 70 * Handles | 104 * Handles |
| 71 * ======= | 105 * ======= |
| 72 */ | 106 */ |
| 73 | 107 |
| 74 /** | 108 /** |
| 75 * An isolate is the unit of concurrency in Dart. Each isolate has | |
| 76 * its own memory and thread of control. No state is shared between | |
| 77 * isolates. Instead, isolates communicate by message passing. | |
| 78 * | |
| 79 * Each thread keeps track of its current isolate, which is the | |
| 80 * isolate which is ready to execute on the current thread. The | |
| 81 * current isolate may be NULL, in which case no isolate is ready to | |
| 82 * execute. Most of the Dart apis require there to be a current | |
| 83 * isolate in order to function without error. The current isolate is | |
| 84 * set by any call to Dart_CreateIsolate or Dart_EnterIsolate. | |
| 85 */ | |
| 86 typedef struct _Dart_Isolate* Dart_Isolate; | |
| 87 | |
| 88 /** | |
| 89 * An object reference managed by the Dart VM garbage collector. | 109 * An object reference managed by the Dart VM garbage collector. |
| 90 * | 110 * |
| 91 * Because the garbage collector may move objects, it is unsafe to | 111 * Because the garbage collector may move objects, it is unsafe to |
| 92 * refer to objects directly. Instead, we refer to objects through | 112 * refer to objects directly. Instead, we refer to objects through |
| 93 * handles, which are known to the garbage collector and updated | 113 * handles, which are known to the garbage collector and updated |
| 94 * automatically when the object is moved. Handles should be passed | 114 * automatically when the object is moved. Handles should be passed |
| 95 * by value (except in cases like out-parameters) and should never be | 115 * by value (except in cases like out-parameters) and should never be |
| 96 * allocated on the heap. | 116 * allocated on the heap. |
| 97 * | 117 * |
| 98 * Most functions in the Dart Embedding API return a handle. When a | 118 * Most functions in the Dart Embedding API return a handle. When a |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 * Returns the callback data associated with the current Isolate. This data was | 950 * Returns the callback data associated with the current Isolate. This data was |
| 931 * passed to the isolate when it was created. | 951 * passed to the isolate when it was created. |
| 932 */ | 952 */ |
| 933 DART_EXPORT void* Dart_CurrentIsolateData(); | 953 DART_EXPORT void* Dart_CurrentIsolateData(); |
| 934 | 954 |
| 935 /** | 955 /** |
| 936 * Returns the callback data associated with the specified Isolate. This data | 956 * Returns the callback data associated with the specified Isolate. This data |
| 937 * was passed to the isolate when it was created. | 957 * was passed to the isolate when it was created. |
| 938 * The embedder is responsible for ensuring the consistency of this data | 958 * The embedder is responsible for ensuring the consistency of this data |
| 939 * with respect to the lifecycle of an Isolate. | 959 * with respect to the lifecycle of an Isolate. |
| 960 * |
| 961 * \return pointer to data or NULL if the isolate could not be found. |
| 940 */ | 962 */ |
| 941 DART_EXPORT void* Dart_IsolateData(Dart_Isolate isolate); | 963 DART_EXPORT void* Dart_IsolateData(Dart_Isolate isolate); |
| 942 | 964 |
| 943 /** | 965 /** |
| 944 * Returns the debugging name for the current isolate. | 966 * Returns the debugging name for the current isolate. |
| 945 * | 967 * |
| 946 * This name is unique to each isolate and should only be used to make | 968 * This name is unique to each isolate and should only be used to make |
| 947 * debugging messages more comprehensible. | 969 * debugging messages more comprehensible. |
| 948 */ | 970 */ |
| 949 DART_EXPORT Dart_Handle Dart_DebugName(); | 971 DART_EXPORT Dart_Handle Dart_DebugName(); |
| 950 | 972 |
| 951 /** | 973 /** |
| 952 * Enters an isolate. After calling this function, | 974 * Enters an isolate. After calling this function, |
| 953 * the current isolate will be set to the provided isolate. | 975 * the current isolate will be set to the provided isolate. |
| 954 * | 976 * |
| 955 * Requires there to be no current isolate. Multiple threads may not be in | 977 * Requires there to be no current isolate. Multiple threads may not be in |
| 956 * the same isolate at once. | 978 * the same isolate at once. |
| 979 * |
| 980 * \return true if isolate was entered, false otherwise. |
| 957 */ | 981 */ |
| 958 DART_EXPORT void Dart_EnterIsolate(Dart_Isolate isolate); | 982 DART_EXPORT bool Dart_EnterIsolate(Dart_Isolate isolate); |
| 959 | 983 |
| 960 /** | 984 /** |
| 961 * Notifies the VM that the current isolate is about to make a blocking call. | 985 * Notifies the VM that the current isolate is about to make a blocking call. |
| 962 */ | 986 */ |
| 963 DART_EXPORT void Dart_IsolateBlocked(); | 987 DART_EXPORT void Dart_IsolateBlocked(); |
| 964 | 988 |
| 965 /** | 989 /** |
| 966 * Notifies the VM that the current isolate is no longer blocked. | 990 * Notifies the VM that the current isolate is no longer blocked. |
| 967 */ | 991 */ |
| 968 DART_EXPORT void Dart_IsolateUnblocked(); | 992 DART_EXPORT void Dart_IsolateUnblocked(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 intptr_t* size); | 1057 intptr_t* size); |
| 1034 | 1058 |
| 1035 /** | 1059 /** |
| 1036 * Schedules an interrupt for the specified isolate. | 1060 * Schedules an interrupt for the specified isolate. |
| 1037 * | 1061 * |
| 1038 * When the isolate is interrupted, the isolate interrupt callback | 1062 * When the isolate is interrupted, the isolate interrupt callback |
| 1039 * will be invoked with 'isolate' as the current isolate (see | 1063 * will be invoked with 'isolate' as the current isolate (see |
| 1040 * Dart_IsolateInterruptCallback). | 1064 * Dart_IsolateInterruptCallback). |
| 1041 * | 1065 * |
| 1042 * \param isolate The isolate to be interrupted. | 1066 * \param isolate The isolate to be interrupted. |
| 1067 * |
| 1068 * \return true if isolate is scheduled to be be interrupted, false otherwise. |
| 1043 */ | 1069 */ |
| 1044 DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate); | 1070 DART_EXPORT bool Dart_InterruptIsolate(Dart_Isolate isolate); |
| 1045 | 1071 |
| 1046 /** | 1072 /** |
| 1047 * Make isolate runnable. | 1073 * Make isolate runnable. |
| 1048 * | 1074 * |
| 1049 * When isolates are spawned this function is used to indicate that | 1075 * When isolates are spawned this function is used to indicate that |
| 1050 * the creation and initialization (including script loading) of the | 1076 * the creation and initialization (including script loading) of the |
| 1051 * isolate is complete and the isolate can start. | 1077 * isolate is complete and the isolate can start. |
| 1052 * This function does not expect there to be a current isolate. | 1078 * This function does not expect there to be a current isolate. |
| 1053 * | 1079 * |
| 1054 * \param isolate The isolate to be made runnable. | 1080 * \param isolate The isolate to be made runnable. |
| 1081 * |
| 1082 * \return true if isolate was made runnable, false otherwise. |
| 1055 */ | 1083 */ |
| 1056 DART_EXPORT bool Dart_IsolateMakeRunnable(Dart_Isolate isolate); | 1084 DART_EXPORT bool Dart_IsolateMakeRunnable(Dart_Isolate isolate); |
| 1057 | 1085 |
| 1058 | 1086 |
| 1059 /* | 1087 /* |
| 1060 * ================== | 1088 * ================== |
| 1061 * Messages and Ports | 1089 * Messages and Ports |
| 1062 * ================== | 1090 * ================== |
| 1063 */ | 1091 */ |
| 1064 | 1092 |
| 1065 /** | 1093 /** |
| 1066 * A port is used to send or receive inter-isolate messages | 1094 * DART_ILLEGAL_PORT is a port number guaranteed never to be associated with a |
| 1095 * valid port. |
| 1067 */ | 1096 */ |
| 1068 typedef int64_t Dart_Port; | 1097 #define DART_ILLEGAL_PORT ((Dart_Port) 0) |
| 1069 | |
| 1070 /** | |
| 1071 * ILLEGAL_PORT is a port number guaranteed never to be associated with a valid | |
| 1072 * port. | |
| 1073 */ | |
| 1074 #define ILLEGAL_PORT ((Dart_Port) 0) | |
| 1075 | 1098 |
| 1076 /** | 1099 /** |
| 1077 * A message notification callback. | 1100 * A message notification callback. |
| 1078 * | 1101 * |
| 1079 * This callback allows the embedder to provide an alternate wakeup | 1102 * This callback allows the embedder to provide an alternate wakeup |
| 1080 * mechanism for the delivery of inter-isolate messages. It is the | 1103 * mechanism for the delivery of inter-isolate messages. It is the |
| 1081 * responsibility of the embedder to call Dart_HandleMessage to | 1104 * responsibility of the embedder to call Dart_HandleMessage to |
| 1082 * process the message. | 1105 * process the message. |
| 1083 */ | 1106 */ |
| 1084 typedef void (*Dart_MessageNotifyCallback)(Dart_Isolate dest_isolate); | 1107 typedef void (*Dart_MessageNotifyCallback)(Dart_Isolate dest_isolate); |
| (...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2779 * \param isolate An isolate | 2802 * \param isolate An isolate |
| 2780 * | 2803 * |
| 2781 * \return Returns true if 'isolate' is the service isolate. | 2804 * \return Returns true if 'isolate' is the service isolate. |
| 2782 */ | 2805 */ |
| 2783 DART_EXPORT bool Dart_IsServiceIsolate(Dart_Isolate isolate); | 2806 DART_EXPORT bool Dart_IsServiceIsolate(Dart_Isolate isolate); |
| 2784 | 2807 |
| 2785 | 2808 |
| 2786 /** | 2809 /** |
| 2787 * Returns the port that script load requests should be sent on. | 2810 * Returns the port that script load requests should be sent on. |
| 2788 * | 2811 * |
| 2789 * \return Returns the port for load requests or ILLEGAL_PORT if the service | 2812 * \return Returns the port for load requests or DART_ILLEGAL_PORT if the |
| 2790 * isolate failed to startup or does not support load requests. | 2813 * service isolate failed to startup or does not support load requests. |
| 2791 */ | 2814 */ |
| 2792 DART_EXPORT Dart_Port Dart_ServiceWaitForLoadPort(); | 2815 DART_EXPORT Dart_Port Dart_ServiceWaitForLoadPort(); |
| 2793 | 2816 |
| 2794 | 2817 |
| 2795 /** | 2818 /** |
| 2796 * A service request callback function. | 2819 * A service request callback function. |
| 2797 * | 2820 * |
| 2798 * These callbacks, registered by the embedder, are called when the VM receives | 2821 * These callbacks, registered by the embedder, are called when the VM receives |
| 2799 * a service request it can't handle and the service request command name | 2822 * a service request it can't handle and the service request command name |
| 2800 * matches one of the embedder registered handlers. | 2823 * matches one of the embedder registered handlers. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2844 * NOTE: If multiple callbacks with the same name are registered, only the | 2867 * NOTE: If multiple callbacks with the same name are registered, only the |
| 2845 * last callback registered will be remembered. | 2868 * last callback registered will be remembered. |
| 2846 */ | 2869 */ |
| 2847 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( | 2870 DART_EXPORT void Dart_RegisterRootServiceRequestCallback( |
| 2848 const char* name, | 2871 const char* name, |
| 2849 Dart_ServiceRequestCallback callback, | 2872 Dart_ServiceRequestCallback callback, |
| 2850 void* user_data); | 2873 void* user_data); |
| 2851 | 2874 |
| 2852 | 2875 |
| 2853 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ | 2876 #endif /* INCLUDE_DART_API_H_ */ /* NOLINT */ |
| OLD | NEW |