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

Unified Diff: lib/ports.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/ports.dart
diff --git a/lib/ports.dart b/lib/ports.dart
index c8de655819f4bd93f26590b19dd54f4fb8be4ffb..fa29db16fb4761ee4475dc7195d1749a81fa8b48 100644
--- a/lib/ports.dart
+++ b/lib/ports.dart
@@ -46,8 +46,7 @@ import "src/lists.dart";
* .sendPort
*/
SendPort singleCallbackPort(void callback(response),
- {Duration timeout,
- var timeoutValue}) {
+ {Duration timeout, var timeoutValue}) {
Lasse Reichstein Nielsen 2015/02/26 10:59:14 Indent '{' to after '('.
RawReceivePort responsePort = new RawReceivePort();
Zone zone = Zone.current;
callback = zone.registerUnaryCallback(callback);
@@ -94,9 +93,7 @@ SendPort singleCallbackPort(void callback(response),
* Returns the `SendPort` expecting the single message.
*/
SendPort singleCompletePort(Completer completer,
- {callback(message),
- Duration timeout,
- onTimeout()}) {
+ {callback(message), Duration timeout, onTimeout()}) {
Lasse Reichstein Nielsen 2015/02/26 10:59:14 Indent '{' to after '(' or put the completer on a
if (callback == null && timeout == null) {
return singleCallbackPort(completer.complete);
}
@@ -125,8 +122,8 @@ SendPort singleCompletePort(Completer completer,
if (onTimeout != null) {
completer.complete(new Future.sync(onTimeout));
} else {
- completer.completeError(new TimeoutException("Future not completed",
- timeout));
+ completer.completeError(
+ new TimeoutException("Future not completed", timeout));
}
});
}
@@ -156,8 +153,7 @@ SendPort singleCompletePort(Completer completer,
* The `Future` method won't be able to close the underlying [ReceivePort].
*/
Future singleResponseFuture(void action(SendPort responsePort),
- {Duration timeout,
- var timeoutValue}) {
+ {Duration timeout, var timeoutValue}) {
Lasse Reichstein Nielsen 2015/02/26 10:59:14 Indentation again.
Completer completer = new Completer.sync();
RawReceivePort responsePort = new RawReceivePort();
Timer timer;
@@ -181,12 +177,13 @@ Future singleResponseFuture(void action(SendPort responsePort),
responsePort.close();
if (timer != null) timer.cancel();
// Delay completion because completer is sync.
- scheduleMicrotask(() { completer.completeError(e, s); });
+ scheduleMicrotask(() {
+ completer.completeError(e, s);
+ });
}
return completer.future;
}
-
/**
* Send the result of a future, either value or error, as a message.
*
@@ -195,11 +192,13 @@ Future singleResponseFuture(void action(SendPort responsePort),
* by the port of [singleResultFuture].
*/
void sendFutureResult(Future future, SendPort resultPort) {
- future.then((v) { resultPort.send(list1(v)); },
- onError: (e, s) { resultPort.send(list2("$e", "$s")); });
+ future.then((v) {
+ resultPort.send(list1(v));
+ }, onError: (e, s) {
+ resultPort.send(list2("$e", "$s"));
+ });
}
-
/**
* Creates a [Future], and a [SendPort] that can be used to complete that
* future.
@@ -221,13 +220,10 @@ void sendFutureResult(Future future, SendPort resultPort) {
* a [TimeoutException].
*/
Future singleResultFuture(void action(SendPort responsePort),
- {Duration timeout,
- onTimeout()}) {
+ {Duration timeout, onTimeout()}) {
Lasse Reichstein Nielsen 2015/02/26 10:59:14 Indent '{'.
Completer completer = new Completer.sync();
SendPort port = singleCompletePort(completer,
- callback: receiveFutureResult,
- timeout: timeout,
- onTimeout: onTimeout);
+ callback: receiveFutureResult, timeout: timeout, onTimeout: onTimeout);
Lasse Reichstein Nielsen 2015/02/26 10:59:14 Put completer on a new line too, or indent as orig
try {
action(port);
} catch (e, s) {
@@ -252,7 +248,6 @@ void completeFutureResult(var response, Completer completer) {
}
}
-
Lasse Reichstein Nielsen 2015/02/26 10:59:14 I'm not sure I always want single lines between fu
/**
* Convertes a received message created by [sendFutureResult] to a future
* result.

Powered by Google App Engine
This is Rietveld 408576698