OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of dart.isolate; | 5 part of dart.isolate; |
6 | 6 |
7 class IsolateSpawnException implements Exception { | 7 class IsolateSpawnException implements Exception { |
8 const IsolateSpawnException(String this._s); | 8 const IsolateSpawnException(String this._s); |
9 String toString() => "IsolateSpawnException: '$_s'"; | 9 String toString() => "IsolateSpawnException: '$_s'"; |
10 final String _s; | 10 final String _s; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 void close(); | 132 void close(); |
133 | 133 |
134 /** | 134 /** |
135 * Creates a new send port that sends to this receive port. It is legal to | 135 * Creates a new send port that sends to this receive port. It is legal to |
136 * create several [SendPort]s from the same [ReceivePort]. | 136 * create several [SendPort]s from the same [ReceivePort]. |
137 */ | 137 */ |
138 SendPort toSendPort(); | 138 SendPort toSendPort(); |
139 | 139 |
140 } | 140 } |
141 | 141 |
142 // TODO(kasperl): Document this. | 142 /** |
| 143 * [SendPortSync]s are created from [ReceivePortSync]s. Any message sent through |
| 144 * a [SendPortSync] is delivered to its respective [ReceivePortSync]. There |
| 145 * might be many [SendPortSync]s for the same [ReceivePortSync]. |
| 146 * |
| 147 * [SendPortSync]s can be transmitted to other isolates. |
| 148 */ |
143 abstract class SendPortSync { | 149 abstract class SendPortSync { |
144 | 150 /** |
| 151 * Sends a synchronous message to this send port and returns the result. |
| 152 */ |
145 callSync(var message); | 153 callSync(var message); |
146 | 154 |
| 155 /** |
| 156 * Tests whether [other] is a [SendPortSync] pointing to the same |
| 157 * [ReceivePortSync] as this one. |
| 158 */ |
| 159 bool operator==(var other); |
| 160 |
| 161 /** |
| 162 * Returns an immutable hash code for this send port that is |
| 163 * consistent with the == operator. |
| 164 */ |
| 165 int get hashCode; |
147 } | 166 } |
148 | 167 |
149 // The VM doesn't support accessing external globals in the same library. We | 168 // The VM doesn't support accessing external globals in the same library. We |
150 // therefore create this wrapper class. | 169 // therefore create this wrapper class. |
151 // TODO(6997): Don't go through static class for external variables. | 170 // TODO(6997): Don't go through static class for external variables. |
152 abstract class _Isolate { | 171 abstract class _Isolate { |
153 external static ReceivePort get port; | 172 external static ReceivePort get port; |
154 external static SendPort spawnFunction(void topLevelFunction(), | 173 external static SendPort spawnFunction(void topLevelFunction(), |
155 [bool UnhandledExceptionCallback(IsolateUnhandledException e)]); | 174 [bool UnhandledExceptionCallback(IsolateUnhandledException e)]); |
156 external static SendPort spawnUri(String uri); | 175 external static SendPort spawnUri(String uri); |
(...skipping 17 matching lines...) Expand all Loading... |
174 const IsolateUnhandledException(this.message, this.source, this.stackTrace); | 193 const IsolateUnhandledException(this.message, this.source, this.stackTrace); |
175 | 194 |
176 String toString() { | 195 String toString() { |
177 return 'IsolateUnhandledException: exception while handling message: ' | 196 return 'IsolateUnhandledException: exception while handling message: ' |
178 '${message} \n ' | 197 '${message} \n ' |
179 '${source.toString().replaceAll("\n", "\n ")}\n' | 198 '${source.toString().replaceAll("\n", "\n ")}\n' |
180 'original stack trace:\n ' | 199 'original stack trace:\n ' |
181 '${stackTrace.toString().replaceAll("\n","\n ")}'; | 200 '${stackTrace.toString().replaceAll("\n","\n ")}'; |
182 } | 201 } |
183 } | 202 } |
OLD | NEW |