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

Side by Side Diff: lib/isolate/isolate_frog.dart

Issue 9521007: isolates: remove Isolate2 interface, add top-level spawn functions, more comments (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 months 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
« no previous file with comments | « lib/isolate/isolate_compiler.dart ('k') | runtime/lib/isolate.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 5
6 // Dart isolate's API and implementation for frog. 6 // Dart isolate's API and implementation for frog. Since dartdocs are generated
7 // using frog, we include here some additional library level comments.
8
9 /**
10 * The `dart:isolate` library defines APIs to spawn and communicate with
11 * isolates.
12 *
13 * All code in dart runs in the context of an isolate. Each isolate has its own
14 * heap, which means that all values in memory, including globals, are available
15 * only to that isolate. The only mechanism available to communicate between
16 * isolates is to pass messages. Messages are sent through ports. This library
17 * defines [ReceivePort] to represent the receiver's end of a communication
18 * channel, and [SendPort] to represent the sender's end.
19 *
20 * All isolates start with an initial receive port, which is set in the
21 * top-level property [port]. This port is used to establish the first
22 * communication between isolates.
23 *
24 * Two APIs are available to spawn a new isolate: [spawnFunction] and
25 * [spawnUri]. [spawnFunction] creates a new isolate that is using the same
26 * source code as the current isolate, [spawnUri] allows spawning an isolate
27 * that was written independently.
28 *
29 * There is currently no way to indicate in the API whether the isolates should
30 * run on the same or different threads. The underlying system will schedule the
31 * isolate were appropriate. In the near future we will add an API to create DOM
32 * isolates. These are isolates that share access to the DOM. All DOM isolates
33 * will run on the UI thread.
34 *
35 * This library is still evolving. New APIs are being added, and some will be
36 * deprecated and removed. In particular, the class [Isolate] will be
37 * deprecated as soon the dartvm has an implementation working for
38 * [spawnFunction] and [spawnUri], and we have an API to spawn DOM isolates.
39 */
7 #library("dart:isolate"); 40 #library("dart:isolate");
8 41
9 #import("../uri/uri.dart"); 42 #import("../uri/uri.dart");
10 #source("isolate_api.dart"); 43 #source("isolate_api.dart");
11 #source("frog/compiler_hooks.dart"); 44 #source("frog/compiler_hooks.dart");
12 #source("frog/isolateimpl.dart"); 45 #source("frog/isolateimpl.dart");
13 #source("frog/ports.dart"); 46 #source("frog/ports.dart");
14 #source("frog/messages.dart"); 47 #source("frog/messages.dart");
15 #native("frog/natives.js"); 48 #native("frog/natives.js");
16 49
17 /** Default factory for [Isolate2]. */ 50 ReceivePort _port;
18 class _IsolateFactory {
19 51
20 factory Isolate2.fromCode(Function topLevelFunction) { 52 SendPort _spawnFunction(void topLevelFunction()) {
21 final name = _IsolateNatives._getJSFunctionName(topLevelFunction); 53 final name = _IsolateNatives._getJSFunctionName(topLevelFunction);
22 if (name == null) { 54 if (name == null) {
23 throw new UnsupportedOperationException( 55 throw new UnsupportedOperationException(
24 "only top-level functions can be spawned."); 56 "only top-level functions can be spawned.");
25 }
26 return new _Isolate2Impl(_IsolateNatives._spawn2(name, null, false));
27 } 57 }
58 return _IsolateNatives._spawn2(name, null, false);
59 }
28 60
29 factory Isolate2.fromUri(String uri) { 61 SendPort _spawnUri(String uri) {
30 return new _Isolate2Impl(_IsolateNatives._spawn2(null, uri, false)); 62 return _IsolateNatives._spawn2(null, uri, false);
31 }
32 } 63 }
OLDNEW
« no previous file with comments | « lib/isolate/isolate_compiler.dart ('k') | runtime/lib/isolate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698