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

Unified Diff: corelib/src/implementation/promise_implementation.dart

Issue 8403040: Don't wait unnecessarily. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | « compiler/lib/implementation/isolate_serialization.dart ('k') | corelib/src/promise.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: corelib/src/implementation/promise_implementation.dart
===================================================================
--- corelib/src/implementation/promise_implementation.dart (revision 1134)
+++ corelib/src/implementation/promise_implementation.dart (working copy)
@@ -262,32 +262,32 @@
}
}
-class ProxyBase {
+// For now, extend Promise<bool> rather than either
+// a) create a new base, Completable, for Promise and Proxy, or
+// b) extend Promise<SendPort> which would expose the port.
+class ProxyBase extends PromiseImpl<bool> {
ProxyBase.forPort(SendPort port) {
_promise = new Promise<SendPort>();
_promise.complete(port);
+ complete(true);
}
// Construct a proxy for a message reply; see the [Proxy.forReply]
// documentation for more details.
ProxyBase.forReply(Promise<SendPort> port) {
_promise = port;
+ port.addCompleteHandler((_) => complete(true));
}
- // Note that comparing proxies or using them in maps is illegal
- // until they complete.
+ // Note that comparing proxies or using them in maps or sets is
+ // illegal until they complete.
bool operator ==(var other) {
return (other is ProxyBase) && _promise.value == other._promise.value;
}
int hashCode() => _promise.value.hashCode();
- // TODO: consider making this extend Promise<SendPort> instead?
- void addCompleteHandler(void completeHandler()) {
- _promise.addCompleteHandler((_) => completeHandler());
- }
-
static ReceivePort register(Dispatcher dispatcher) {
if (_dispatchers === null) {
_dispatchers = new Map<SendPort, Dispatcher>();
@@ -332,7 +332,7 @@
// function. Any promises are converted to a port which expects to
// receive a port from the other side down which the remote promise
// can be completed by sending the promise's completion value.
- Promise _marshal(List message, process(List marshalled)) {
+ Promise _marshal(List message, process(List marshalled)) {
return _promise.then((SendPort port) {
List marshalled = new List(message.length);
@@ -358,7 +358,7 @@
});
entry.addCompleteHandler((value) {
completer.addCompleteHandler((SendPort port) {
- port.send([value], null);
+ _marshal([value], (List message) => port.send(message, null));
});
});
} else {
« no previous file with comments | « compiler/lib/implementation/isolate_serialization.dart ('k') | corelib/src/promise.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698