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

Unified Diff: lib/isolaterunner.dart

Issue 955053002: adding codereview file, formatting, adding gitignore (Closed) Base URL: https://github.com/dart-lang/isolate.git@master
Patch Set: Created 5 years, 10 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
Index: lib/isolaterunner.dart
diff --git a/lib/isolaterunner.dart b/lib/isolaterunner.dart
index 7e15a406abe2bec1c5c4dd0d33e92172eba92e40..987621a54ec8e08a975d6c569d59966928cd25dd 100644
--- a/lib/isolaterunner.dart
+++ b/lib/isolaterunner.dart
@@ -59,16 +59,16 @@ class IsolateRunner implements Runner {
static Future<IsolateRunner> spawn() {
Completer portCompleter = new Completer.sync();
SendPort initPort = singleCompletePort(portCompleter);
- return Isolate.spawn(IsolateRunnerRemote._create, initPort)
- .then((Isolate isolate) {
- // TODO: Add when VM supports it.
- // isolate.setErrorsFatal(false);
- return portCompleter.future.then((SendPort commandPort) {
- var result = new IsolateRunner(isolate, commandPort);
- // Guarantees that setErrorsFatal has completed.
- return result.ping().then((_) => result);
- });
- });
+ return Isolate.spawn(IsolateRunnerRemote._create, initPort).then(
+ (Isolate isolate) {
Lasse Reichstein Nielsen 2015/02/26 10:59:14 Also has body less indented than its delimiter lin
+ // TODO: Add when VM supports it.
+ // isolate.setErrorsFatal(false);
+ return portCompleter.future.then((SendPort commandPort) {
+ var result = new IsolateRunner(isolate, commandPort);
+ // Guarantees that setErrorsFatal has completed.
+ return result.ping().then((_) => result);
+ });
+ });
}
/**
@@ -138,9 +138,7 @@ class IsolateRunner implements Runner {
Future<bool> ping({Duration timeout: const Duration(seconds: 1)}) {
Completer completer = new Completer<bool>();
SendPort port = singleCompletePort(completer,
- callback: _kTrue,
- timeout: timeout,
- onTimeout: _kFalse);
+ callback: _kTrue, timeout: timeout, onTimeout: _kFalse);
Lasse Reichstein Nielsen 2015/02/26 10:59:13 I prefer the original.
isolate.ping(port);
return completer.future;
}
@@ -204,11 +202,10 @@ class IsolateRunner implements Runner {
* await iso.close();
* }
*/
- Future run(function(argument), argument,
- {Duration timeout, onTimeout()}) {
+ Future run(function(argument), argument, {Duration timeout, onTimeout()}) {
return singleResultFuture((SendPort port) {
- _commandPort.send(
- list4(_RUN, FunctionRef.from(function), argument, port));
+ _commandPort
+ .send(list4(_RUN, FunctionRef.from(function), argument, port));
}, timeout: timeout, onTimeout: onTimeout);
}
@@ -236,22 +233,19 @@ class IsolateRunner implements Runner {
controller.addError(error, error.stackTrace);
}
}
- controller = new StreamController.broadcast(
- sync: true,
- onListen: () {
- port = new RawReceivePort(handleError);
- // TODO: When supported, uncomment this.
- // isolate.addErrorListener(port.sendPort);
- // isolate.addOnExitListener(port.sendPort);
- // And remove the send below, which acts as an immediate close.
- port.sendPort.send(null);
- },
- onCancel: () {
- port.close();
- // this.removeErrorListener(port.sendPort);
- // this.removeOnExitListener(port.sendPort);
- port = null;
- });
+ controller = new StreamController.broadcast(sync: true, onListen: () {
+ port = new RawReceivePort(handleError);
+ // TODO: When supported, uncomment this.
+ // isolate.addErrorListener(port.sendPort);
+ // isolate.addOnExitListener(port.sendPort);
+ // And remove the send below, which acts as an immediate close.
+ port.sendPort.send(null);
+ }, onCancel: () {
+ port.close();
+ // this.removeErrorListener(port.sendPort);
+ // this.removeOnExitListener(port.sendPort);
+ port = null;
+ });
Lasse Reichstein Nielsen 2015/02/26 10:59:13 Less consistently indented. I'd prefer the onListe
return controller.stream;
}
@@ -312,8 +306,8 @@ class IsolateRunnerRemote {
Function function = command[1].function;
var argument = command[2];
SendPort responsePort = command[3];
- sendFutureResult(new Future.sync(() => function(argument)),
- responsePort);
+ sendFutureResult(
+ new Future.sync(() => function(argument)), responsePort);
Lasse Reichstein Nielsen 2015/02/26 10:59:14 It's not as visible that responsePort is a second
return;
}
}

Powered by Google App Engine
This is Rietveld 408576698