Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: sdk/lib/isolate/base.dart

Issue 11308154: Stream isolates. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Fixes and test. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 class IsolateSpawnException implements Exception { 5 class IsolateSpawnException implements Exception {
6 const IsolateSpawnException(String this._s); 6 const IsolateSpawnException(String this._s);
7 String toString() => "IsolateSpawnException: '$_s'"; 7 String toString() => "IsolateSpawnException: '$_s'";
8 final String _s; 8 final String _s;
9 } 9 }
10 10
11 /** 11 /**
12 * The initial [ReceivePort] available by default for this isolate. This 12 * The initial [ReceivePort] available by default for this isolate. This
13 * [ReceivePort] is created automatically and it is commonly used to establish 13 * [ReceivePort] is created automatically and it is commonly used to establish
14 * the first communication between isolates (see [spawnFunction] and 14 * the first communication between isolates (see [spawnFunction] and
15 * [spawnUri]). 15 * [spawnUri]).
16 */ 16 */
17 external ReceivePort get port; 17 ReceivePort get port => _Isolate.port;
18 18
19 /** 19 /**
20 * Creates and spawns an isolate that shares the same code as the current 20 * Creates and spawns an isolate that shares the same code as the current
21 * isolate, but that starts from [topLevelFunction]. The [topLevelFunction] 21 * isolate, but that starts from [topLevelFunction]. The [topLevelFunction]
22 * argument must be a static top-level function or a static method that takes no 22 * argument must be a static top-level function or a static method that takes no
23 * arguments. It is illegal to pass a function closure. 23 * arguments. It is illegal to pass a function closure.
24 * 24 *
25 * When any isolate starts (even the main script of the application), a default 25 * When any isolate starts (even the main script of the application), a default
26 * [ReceivePort] is created for it. This port is available from the top-level 26 * [ReceivePort] is created for it. This port is available from the top-level
27 * getter [port] defined in this library. 27 * getter [port] defined in this library.
28 * 28 *
29 * [spawnFunction] returns a [SendPort] derived from the child isolate's default 29 * [spawnFunction] returns a [SendPort] derived from the child isolate's default
30 * port. 30 * port.
31 * 31 *
32 * See comments at the top of this library for more details. 32 * See comments at the top of this library for more details.
33 */ 33 */
34 // Note this feature is not yet available in the dartvm. 34 SendPort spawnFunction(void topLevelFunction())
35 external SendPort spawnFunction(void topLevelFunction()); 35 => _Isolate.spawnFunction(topLevelFunction);
36 36
37 /** 37 /**
38 * Creates and spawns an isolate whose code is available at [uri]. Like with 38 * Creates and spawns an isolate whose code is available at [uri]. Like with
39 * [spawnFunction], the child isolate will have a default [ReceivePort], and a 39 * [spawnFunction], the child isolate will have a default [ReceivePort], and a
40 * this function returns a [SendPort] derived from it. 40 * this function returns a [SendPort] derived from it.
41 * 41 *
42 * See comments at the top of this library for more details. 42 * See comments at the top of this library for more details.
43 */ 43 */
44 external SendPort spawnUri(String uri); 44 SendPort spawnUri(String uri) => _Isolate.spawnUri(uri);
45 45
46 /** 46 /**
47 * [SendPort]s are created from [ReceivePort]s. Any message sent through 47 * [SendPort]s are created from [ReceivePort]s. Any message sent through
48 * a [SendPort] is delivered to its respective [ReceivePort]. There might be 48 * a [SendPort] is delivered to its respective [ReceivePort]. There might be
49 * many [SendPort]s for the same [ReceivePort]. 49 * many [SendPort]s for the same [ReceivePort].
50 * 50 *
51 * [SendPort]s can be transmitted to other isolates. 51 * [SendPort]s can be transmitted to other isolates.
52 */ 52 */
53 abstract class SendPort { 53 abstract class SendPort {
54 54
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 SendPort toSendPort(); 135 SendPort toSendPort();
136 136
137 } 137 }
138 138
139 // TODO(kasperl): Document this. 139 // TODO(kasperl): Document this.
140 abstract class SendPortSync { 140 abstract class SendPortSync {
141 141
142 callSync(var message); 142 callSync(var message);
143 143
144 } 144 }
145
146 // The VM doesn't support accessing external globals in the same library. We
Ivan Posva 2012/11/26 18:56:40 Can you please elaborate what is missing from our
floitsch 2012/11/28 14:13:18 We cannot access external global variables from wi
147 // therefore create this wrapper class.
148 // TODO(floitsch): add bug-number.
149 abstract class _Isolate {
150 external static ReceivePort get port;
151 external static SendPort spawnFunction(void topLevelFunction());
152 external static SendPort spawnUri(String uri);
153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698