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

Side by Side Diff: corelib/src/isolate.dart

Issue 8457005: convert isolates to use Future (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updated co19 Created 9 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
« no previous file with comments | « corelib/src/future.dart ('k') | frog/lib/dom/html.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 // Dart core library. 5 // Dart core library.
6 6
7 /** 7 /**
8 * [SendPort]s are created from [ReceivePort]s. Any message sent through 8 * [SendPort]s are created from [ReceivePort]s. Any message sent through
9 * a [SendPort] is delivered to its respective [ReceivePort]. There might be 9 * a [SendPort] is delivered to its respective [ReceivePort]. There might be
10 * many [SendPort]s for the same [ReceivePort]. 10 * many [SendPort]s for the same [ReceivePort].
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 /** 130 /**
131 * Spawns a new isolate, using this instance as template. 131 * Spawns a new isolate, using this instance as template.
132 * 132 *
133 * The new isolate lives in a new thread (for heavy templates) 133 * The new isolate lives in a new thread (for heavy templates)
134 * or in the same thread as the current isolate (for light templates), if 134 * or in the same thread as the current isolate (for light templates), if
135 * possible. 135 * possible.
136 * 136 *
137 * During the initialization of the new isolate a [ReceivePort] is created 137 * During the initialization of the new isolate a [ReceivePort] is created
138 * inside the new isolate and stored in [port]. A corresponding 138 * inside the new isolate and stored in [port]. A corresponding
139 * [SendPort] is sent to the isolate that invoked [spawn]. Since spawning an 139 * [SendPort] is sent to the isolate that invoked [spawn]. Since spawning an
140 * isolate is an asynchronous operation this method returns a [Promise] of 140 * isolate is an asynchronous operation this method returns a [Future] of
141 * this [SendPort]. 141 * this [SendPort].
142 * 142 *
143 * A common pattern to instantiate new isolates is to enqueue the instructions 143 * A common pattern to instantiate new isolates is to enqueue the instructions
144 * in [Promise.then]. 144 * in [Future.then].
145 * [:myIsolate.spawn().then((SendPort port) { port.send('hi there'); });:] 145 * [:myIsolate.spawn().then((SendPort port) { port.send('hi there'); });:]
146 */ 146 */
147 Promise<SendPort> spawn() { 147 Future<SendPort> spawn() {
148 return IsolateNatives.spawn(this, _isLight); 148 return IsolateNatives.spawn(this, _isLight);
149 } 149 }
150 150
151 // The private run method is invoked with the receive port. Before 151 // The private run method is invoked with the receive port. Before
152 // main is invoked we store the port in a field so it can be 152 // main is invoked we store the port in a field so it can be
153 // accessed from subclasses of Isolate. 153 // accessed from subclasses of Isolate.
154 void _run(ReceivePort port) { 154 void _run(ReceivePort port) {
155 _port = port; 155 _port = port;
156 main(); 156 main();
157 } 157 }
(...skipping 13 matching lines...) Expand all
171 /** 171 /**
172 * When isolates are created, an instance of the template's class is 172 * When isolates are created, an instance of the template's class is
173 * instantiated in the new isolate. After the [port] has been set up, this 173 * instantiated in the new isolate. After the [port] has been set up, this
174 * [main] method is invoked on the instance. 174 * [main] method is invoked on the instance.
175 */ 175 */
176 abstract void main(); 176 abstract void main();
177 177
178 final bool _isLight; 178 final bool _isLight;
179 ReceivePort _port; 179 ReceivePort _port;
180 } 180 }
OLDNEW
« no previous file with comments | « corelib/src/future.dart ('k') | frog/lib/dom/html.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698