| 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 /** | 7 /** |
| 8 * The initial [IsolateStream] available by default for this isolate. This | 8 * The initial [IsolateStream] available by default for this isolate. This |
| 9 * [IsolateStream] is created automatically and it is commonly used to establish | 9 * [IsolateStream] is created automatically and it is commonly used to establish |
| 10 * the first communication between isolates (see [streamSpawnFunction] and | 10 * the first communication between isolates (see [streamSpawnFunction] and |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 * argument must be a static top-level function or a static method that takes no | 189 * argument must be a static top-level function or a static method that takes no |
| 190 * arguments. | 190 * arguments. |
| 191 * | 191 * |
| 192 * When any isolate starts (even the main script of the application), a default | 192 * When any isolate starts (even the main script of the application), a default |
| 193 * [IsolateStream] is created for it. This sink is available from the top-level | 193 * [IsolateStream] is created for it. This sink is available from the top-level |
| 194 * getter [stream] defined in this library. | 194 * getter [stream] defined in this library. |
| 195 * | 195 * |
| 196 * [spawnFunction] returns an [IsolateSink] feeding into the child isolate's | 196 * [spawnFunction] returns an [IsolateSink] feeding into the child isolate's |
| 197 * default stream. | 197 * default stream. |
| 198 * | 198 * |
| 199 * The optional [unhandledExceptionCallback] argument is invoked whenever an |
| 200 * exception inside the isolate is unhandled. It can be seen as a big |
| 201 * `try/catch` around everything that is executed inside the isolate. The |
| 202 * callback should return `true` when it was able to handled the exception. |
| 203 * |
| 199 * See comments at the top of this library for more details. | 204 * See comments at the top of this library for more details. |
| 200 */ | 205 */ |
| 201 IsolateSink streamSpawnFunction(void topLevelFunction()) { | 206 IsolateSink streamSpawnFunction( |
| 202 SendPort sendPort = spawnFunction(topLevelFunction); | 207 void topLevelFunction(), |
| 208 [bool unhandledExceptionCallback(IsolateUnhandledException e)]) { |
| 209 SendPort sendPort = spawnFunction(topLevelFunction, |
| 210 unhandledExceptionCallback); |
| 203 return new IsolateSink._fromPort(sendPort); | 211 return new IsolateSink._fromPort(sendPort); |
| 204 } | 212 } |
| 205 | 213 |
| 206 /** | 214 /** |
| 207 * Creates and spawns an isolate whose code is available at [uri]. Like with | 215 * Creates and spawns an isolate whose code is available at [uri]. Like with |
| 208 * [streamSpawnFunction], the child isolate will have a default [IsolateStream], | 216 * [streamSpawnFunction], the child isolate will have a default [IsolateStream], |
| 209 * and a this function returns an [IsolateSink] feeding into it. | 217 * and a this function returns an [IsolateSink] feeding into it. |
| 210 * | 218 * |
| 211 * See comments at the top of this library for more details. | 219 * See comments at the top of this library for more details. |
| 212 */ | 220 */ |
| 213 IsolateSink streamSpawnUri(String uri) { | 221 IsolateSink streamSpawnUri(String uri) { |
| 214 SendPort sendPort = spawnUri(uri); | 222 SendPort sendPort = spawnUri(uri); |
| 215 return new IsolateSink._fromPort(sendPort); | 223 return new IsolateSink._fromPort(sendPort); |
| 216 } | 224 } |
| OLD | NEW |