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

Unified Diff: runtime/lib/isolate.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 | « runtime/bin/file_impl.dart ('k') | runtime/vm/custom_isolate_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/isolate.dart
diff --git a/runtime/lib/isolate.dart b/runtime/lib/isolate.dart
index 5974946110df22ffe278727c2cc87fa77698106c..40443341878e3c3163048c6ca6cf18997d4930da 100644
--- a/runtime/lib/isolate.dart
+++ b/runtime/lib/isolate.dart
@@ -6,10 +6,6 @@ class _ReceivePortFactory {
factory ReceivePort() {
return new _ReceivePortImpl();
}
-
- factory ReceivePort.singleShot() {
- return new _ReceivePortSingleShotImpl();
- }
}
@@ -67,30 +63,6 @@ class _ReceivePortImpl implements 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() {
- return _port.toSendPort();
- }
-
- final _ReceivePortImpl _port;
-
-}
-
-
class _SendPortImpl implements SendPort {
/*--- public interface ---*/
void send(var message, [SendPort replyTo = null]) {
@@ -102,16 +74,19 @@ class _SendPortImpl implements SendPort {
_sendInternal(_id, replyId, message);
}
- _ReceivePortSingleShotImpl call(var message) {
- final result = new _ReceivePortSingleShotImpl();
- this.send(message, result.toSendPort());
- return result;
- }
-
- _ReceivePortSingleShotImpl _callNow(var message) {
- final result = new _ReceivePortSingleShotImpl();
- this._sendNow(message, result.toSendPort());
- return result;
+ 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;
}
bool operator==(var other) {
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | runtime/vm/custom_isolate_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698