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

Unified Diff: lib/isolate/frog/ports.dart

Issue 9652001: SendPort + ReceivePort changes: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | « lib/isolate/frog/messages.dart ('k') | lib/isolate/isolate_api.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/isolate/frog/ports.dart
diff --git a/lib/isolate/frog/ports.dart b/lib/isolate/frog/ports.dart
index 21f58239180af3bea2403e6a3a419a58eccfc544..12d5b0369aa09a4951089f29fe284105a989a64b 100644
--- a/lib/isolate/frog/ports.dart
+++ b/lib/isolate/frog/ports.dart
@@ -9,12 +9,6 @@ class _BaseSendPort implements SendPort {
_BaseSendPort(this._isolateId);
- _ReceivePortSingleShotImpl call(var message) {
- final result = new _ReceivePortSingleShotImpl();
- this.send(message, result.toSendPort());
- return result;
- }
-
static void checkReplyTo(SendPort replyTo) {
if (replyTo !== null
&& replyTo is! _NativeJsSendPort
@@ -24,20 +18,20 @@ class _BaseSendPort implements SendPort {
}
}
- // TODO(sigmund): replace the current SendPort.call with the following:
- //Future call(var message) {
- //  final completer = new Completer();
- //  final port = new _ReceivePort.singleShot();
- //  send(message, port.toSendPort());
- //  port.receive((value, ignoreReplyTo) {
- //    if (value is Exception) {
- //  completer.completeException(value);
- // } else {
- // completer.complete(value);
- // }
- // });
- //  return completer.future;
- //}
+ Future call(var message) {
+ final completer = new Completer();
+ final port = new _ReceivePortImpl();
+ send(message, port.toSendPort());
+ port.receive((value, ignoreReplyTo) {
+ port.close();
+ if (value is Exception) {
+ completer.completeException(value);
+ } else {
+ completer.complete(value);
+ }
+ });
+ return completer.future;
+ }
abstract void send(var message, [SendPort replyTo]);
abstract bool operator ==(var other);
@@ -187,9 +181,6 @@ class _ReceivePortFactory {
return new _ReceivePortImpl();
}
- factory ReceivePort.singleShot() {
- return new _ReceivePortSingleShotImpl();
- }
}
/** Implementation of a multi-use [ReceivePort] on top of JavaScript. */
@@ -217,27 +208,6 @@ class _ReceivePortImpl implements ReceivePort {
}
}
-/** Implementation of a single-shot [ReceivePort]. */
-class _ReceivePortSingleShotImpl implements ReceivePort {
-
- _ReceivePortSingleShotImpl() : _port = new _ReceivePortImpl() { }
-
- void receive(void callback(var message, SendPort replyTo)) {
- _port.receive((var message, SendPort replyTo) {
- _port.close();
- callback(message, replyTo);
- });
- }
-
- void close() {
- _port.close();
- }
-
- SendPort toSendPort() => _port.toSendPort();
-
- final _ReceivePortImpl _port;
-}
-
/** Wait until all ports in a message are resolved. */
_waitForPendingPorts(var message, void callback()) {
final finder = new _PendingSendPortFinder();
@@ -254,8 +224,6 @@ class _PendingSendPortFinder extends _MessageTraverser {
visitPrimitive(x) {}
visitNativeJsSendPort(_NativeJsSendPort port) {}
visitWorkerSendPort(_WorkerSendPort port) {}
- visitReceivePort(_ReceivePortImpl port) {}
- visitReceivePortSingleShot(_ReceivePortSingleShotImpl port) {}
visitList(List list) {
final visited = _getInfo(list);
« no previous file with comments | « lib/isolate/frog/messages.dart ('k') | lib/isolate/isolate_api.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698