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

Side by Side Diff: runtime/lib/isolate_patch.dart

Issue 312123002: Revert "Ensure that failure to start an isolate all end up in the future." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | « no previous file | runtime/vm/isolate.cc » ('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) 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 import "dart:collection" show HashMap; 5 import "dart:collection" show HashMap;
6 6
7 patch class ReceivePort { 7 patch class ReceivePort {
8 /* patch */ factory ReceivePort() = _ReceivePortImpl; 8 /* patch */ factory ReceivePort() = _ReceivePortImpl;
9 9
10 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = 10 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) =
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // initial startup message has been received. 193 // initial startup message has been received.
194 } 194 }
195 195
196 isolateStartHandler(message) { 196 isolateStartHandler(message) {
197 // We received the initial startup message. Ignore all further messages and 197 // We received the initial startup message. Ignore all further messages and
198 // close the port which kept this isolate alive. 198 // close the port which kept this isolate alive.
199 Isolate._self.handler = ignoreHandler; 199 Isolate._self.handler = ignoreHandler;
200 keepAlivePort.close(); 200 keepAlivePort.close();
201 201
202 SendPort replyTo = message[0]; 202 SendPort replyTo = message[0];
203 if (replyTo != null) {
204 // TODO(floitsch): don't send ok-message if we can't find the entry point.
205 replyTo.send("started");
206 }
203 if (isSpawnUri) { 207 if (isSpawnUri) {
204 assert(message.length == 3); 208 assert(message.length == 3);
205 List<String> args = message[1]; 209 List<String> args = message[1];
206 var isolateMessage = message[2]; 210 var isolateMessage = message[2];
207 if (entryPoint == null) { 211 if (entryPoint is _MainFunctionArgsMessage) {
208 // Set to null when lookup of "main" failed in C++ code.
209 if (replyTo != null) {
210 replyTo.send(["error",
211 "No main method in isolate library"]);
212 }
213 } else if (entryPoint is _MainFunctionArgsMessage) {
214 if (replyTo != null) replyTo.send("started");
215 entryPoint(args, isolateMessage); 212 entryPoint(args, isolateMessage);
216 } else if (entryPoint is _MainFunctionArgs) { 213 } else if (entryPoint is _MainFunctionArgs) {
217 if (replyTo != null) replyTo.send("started");
218 entryPoint(args); 214 entryPoint(args);
219 } else if (entryPoint is _MainFunction) { 215 } else {
220 if (replyTo != null) replyTo.send("started");
221 entryPoint(); 216 entryPoint();
222 } else {
223 // Report error back to spawner.
224 if (replyTo != null) {
225 replyTo.send(["error",
226 "Incorrect parameter count on main: $entryPoint"]);
227 }
228 } 217 }
229 } else { 218 } else {
230 assert(message.length == 2); 219 assert(message.length == 2);
231 var entryMessage = message[1]; 220 var entryMessage = message[1];
232 if (replyTo != null) replyTo.send("started");
233 entryPoint(entryMessage); 221 entryPoint(entryMessage);
234 } 222 }
235 } 223 }
236 224
237 Isolate._self.handler = isolateStartHandler; 225 Isolate._self.handler = isolateStartHandler;
238 } 226 }
239 227
240 patch class Isolate { 228 patch class Isolate {
241 /* patch */ static Future<Isolate> spawn( 229 /* patch */ static Future<Isolate> spawn(
242 void entryPoint(message), var message, { bool paused: false }) { 230 void entryPoint(message), var message, { bool paused: false }) {
(...skipping 18 matching lines...) Expand all
261 /* patch */ static Future<Isolate> spawnUri( 249 /* patch */ static Future<Isolate> spawnUri(
262 Uri uri, List<String> args, var message, { bool paused: false }) { 250 Uri uri, List<String> args, var message, { bool paused: false }) {
263 // `paused` isn't handled yet. 251 // `paused` isn't handled yet.
264 try { 252 try {
265 // The VM will invoke [_startIsolate] and not `main`. 253 // The VM will invoke [_startIsolate] and not `main`.
266 SendPort controlPort = _spawnUri(uri.toString()); 254 SendPort controlPort = _spawnUri(uri.toString());
267 RawReceivePort readyPort = new RawReceivePort(); 255 RawReceivePort readyPort = new RawReceivePort();
268 controlPort.send([readyPort.sendPort, args, message]); 256 controlPort.send([readyPort.sendPort, args, message]);
269 Completer completer = new Completer<Isolate>.sync(); 257 Completer completer = new Completer<Isolate>.sync();
270 readyPort.handler = (readyMessage) { 258 readyPort.handler = (readyMessage) {
259 assert(readyMessage == 'started');
271 readyPort.close(); 260 readyPort.close();
272 if ('started' == readyMessage) { 261 completer.complete(new Isolate(controlPort));
273 completer.complete(new Isolate(controlPort));
274 } else {
275 assert(readyMessage is List && readyMessage[0] == "error");
276 String error = readyMessage[1];
277 var remoteError = new IsolateSpawnException(error);
278 completer.completeError(remoteError);
279 }
280 }; 262 };
281 return completer.future; 263 return completer.future;
282 } catch (e, st) { 264 } catch (e, st) {
283 return new Future<Isolate>.error(e, st); 265 return new Future<Isolate>.error(e, st);
284 }; 266 };
285 return completer.future; 267 return completer.future;
286 } 268 }
287 269
288 static final RawReceivePort _self = _mainPort; 270 static final RawReceivePort _self = _mainPort;
289 static RawReceivePort get _mainPort native "Isolate_mainPort"; 271 static RawReceivePort get _mainPort native "Isolate_mainPort";
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 304 }
323 305
324 /* patch */ void addErrorListener(SendPort port) { 306 /* patch */ void addErrorListener(SendPort port) {
325 throw new UnsupportedError("addErrorListener"); 307 throw new UnsupportedError("addErrorListener");
326 } 308 }
327 309
328 /* patch */ void removeErrorListener(SendPort port) { 310 /* patch */ void removeErrorListener(SendPort port) {
329 throw new UnsupportedError("removeErrorListener"); 311 throw new UnsupportedError("removeErrorListener");
330 } 312 }
331 } 313 }
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698