| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // TODO(sigmund): separate isolates from dart:core |
| 6 // #library('dart:isolate'); |
| 7 |
| 8 /** |
| 9 * [Isolate2] provides APIs to spawn, communicate, and stop an isolate. An |
| 10 * isolate can be spawned by simply creating a new instance of [Isolate2]. The |
| 11 * [Isolate2] instance exposes a port to communicate with the isolate and |
| 12 * methods to control its behavior remotely. |
| 13 */ |
| 14 // TODO(sigmund): rename to Isolate once we delete the old implementation |
| 15 interface Isolate2 default IsolateFactory { |
| 16 |
| 17 /** |
| 18 * Create and spawn an isolate that shares the same code as the current |
| 19 * isolate, but that starts from [topLevelFunction]. The [topLevelFunction] |
| 20 * argument must be a static method closure that takes exactly one |
| 21 * argument of type [ReceivePort]. It is illegal to pass a function closure |
| 22 * that captures values in scope. |
| 23 * |
| 24 * When an child isolate is spawned, a new [ReceivePort] is created for it. |
| 25 * This port is passed to [topLevelFunction]. A [SendPort] derived from |
| 26 * such port is sent to the spawner isolate, which is accessible in |
| 27 * [Isolate2.sendPort] field of this instance. |
| 28 */ |
| 29 Isolate2.fromCode(Function topLevelFunction); |
| 30 |
| 31 /** |
| 32 * Create and spawn an isolate whose code is available at [uri]. |
| 33 * The code in [uri] must have an method called [: isolateMain :], which takes |
| 34 * exactly one argument of type [ReceivePort]. |
| 35 * Like with [Isolate2.fromCode], a [ReceivePort] is created in the child |
| 36 * isolate, and a [SendPort] to it is stored in [Isolate2.sendPort]. |
| 37 */ |
| 38 Isolate2.fromUri(String uri); |
| 39 |
| 40 /** Port used to communicate with this isolate. */ |
| 41 SendPort sendPort; |
| 42 |
| 43 /** Stop this isolate. */ |
| 44 void stop(); |
| 45 } |
| 46 |
| OLD | NEW |