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

Unified Diff: runtime/lib/isolate_patch.dart

Issue 516863002: Revert revision 39617 "Create isolates in a separate thread." (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/isolate.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/isolate_patch.dart
===================================================================
--- runtime/lib/isolate_patch.dart (revision 39634)
+++ runtime/lib/isolate_patch.dart (working copy)
@@ -253,7 +253,18 @@
// The VM will invoke [_startIsolate] with entryPoint as argument.
readyPort = new RawReceivePort();
_spawnFunction(readyPort.sendPort, entryPoint, message);
- return spawnCommon(readyPort);
+ Completer completer = new Completer<Isolate>.sync();
+ readyPort.handler = (readyMessage) {
+ readyPort.close();
+ assert(readyMessage is List);
+ assert(readyMessage.length == 2);
+ SendPort controlPort = readyMessage[0];
+ List capabilities = readyMessage[1];
+ completer.complete(new Isolate(controlPort,
+ pauseCapability: capabilities[0],
+ terminateCapability: capabilities[1]));
+ };
+ return completer.future;
} catch (e, st) {
if (readyPort != null) {
readyPort.close();
@@ -270,34 +281,23 @@
// The VM will invoke [_startIsolate] and not `main`.
readyPort = new RawReceivePort();
_spawnUri(readyPort.sendPort, uri.toString(), args, message);
- return spawnCommon(readyPort);
- } catch (e, st) {
- if (readyPort != null) {
+ Completer completer = new Completer<Isolate>.sync();
+ readyPort.handler = (readyMessage) {
readyPort.close();
- }
- return new Future<Isolate>.error(e, st);
- };
- }
-
- static Future<Isolate> spawnCommon(RawReceivePort readyPort) {
- Completer completer = new Completer<Isolate>.sync();
- readyPort.handler = (readyMessage) {
- readyPort.close();
- if (readyMessage is String) {
- // We encountered an error starting the new isolate.
- completer.completeError(new IsolateSpawnException(
- "Unable to spawn child isolate:\n${readyMessage}"));
- } else if (readyMessage is List &&
- readyMessage.length == 2) {
+ assert(readyMessage is List);
+ assert(readyMessage.length == 2);
SendPort controlPort = readyMessage[0];
List capabilities = readyMessage[1];
completer.complete(new Isolate(controlPort,
pauseCapability: capabilities[0],
terminateCapability: capabilities[1]));
- } else {
- completer.completeError(new IsolateSpawnException(
- "Internal error: received unexpected message $readyMessage"));
+ };
+ return completer.future;
+ } catch (e, st) {
+ if (readyPort != null) {
+ readyPort.close();
}
+ return new Future<Isolate>.error(e, st);
};
return completer.future;
}
« no previous file with comments | « runtime/lib/isolate.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698