| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Dart core library. | 5 // Dart core library. |
| 6 | 6 |
| 7 /** A promise to value of type [T] that may be computed asynchronously. */ | 7 /** A promise to value of type [T] that may be computed asynchronously. */ |
| 8 interface Promise<T> factory PromiseImpl<T> { | 8 interface Promise<T> factory PromiseImpl<T> { |
| 9 | 9 |
| 10 Promise(); | 10 Promise(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 * flatten returns a Promise<T>. | 73 * flatten returns a Promise<T>. |
| 74 */ | 74 */ |
| 75 Promise flatten(); | 75 Promise flatten(); |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * Mark this promise as complete when some or all values in [arr] are | 78 * Mark this promise as complete when some or all values in [arr] are |
| 79 * computed. Every time one of the promises is computed, it is passed to | 79 * computed. Every time one of the promises is computed, it is passed to |
| 80 * [joinDone]. When [joinDone] returns true, this instance is marked as | 80 * [joinDone]. When [joinDone] returns true, this instance is marked as |
| 81 * complete with the last value that was computed. | 81 * complete with the last value that was computed. |
| 82 */ | 82 */ |
| 83 void join(Collection<Promise<T>> arr, bool joinDone(Promise<T> completed)); | 83 void join(Collection<Promise> arr, bool joinDone(Promise completed)); |
| 84 | 84 |
| 85 /** | 85 /** |
| 86 * Mark this promise as complete when [n] promises in [arr] complete, then | 86 * Mark this promise as complete when [n] promises in [arr] complete, then |
| 87 * cancel the rest of the promises in [arr] that didn't complete. | 87 * cancel the rest of the promises in [arr] that didn't complete. |
| 88 */ | 88 */ |
| 89 void waitFor(Collection<Promise> arr, int n); | 89 void waitFor(Collection<Promise> arr, int n); |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 interface Proxy factory ProxyImpl { | 93 interface Proxy extends Promise<bool> factory ProxyImpl { |
| 94 | 94 |
| 95 Proxy.forPort(SendPort port); | 95 Proxy.forPort(SendPort port); |
| 96 Proxy.forIsolate(Isolate isolate); | 96 Proxy.forIsolate(Isolate isolate); |
| 97 Proxy._forIsolateWithPromise(Isolate isolate, Promise<SendPort> promise); | 97 Proxy._forIsolateWithPromise(Isolate isolate, Promise<SendPort> promise); |
| 98 /* | 98 /* |
| 99 * The [Proxy.forReply] constructor is used to create a proxy for | 99 * The [Proxy.forReply] constructor is used to create a proxy for |
| 100 * the object that will be the reply to a message send. | 100 * the object that will be the reply to a message send. |
| 101 */ | 101 */ |
| 102 Proxy.forReply(Promise<SendPort> port); | 102 Proxy.forReply(Promise<SendPort> port); |
| 103 | 103 |
| 104 void send(List message); | 104 void send(List message); |
| 105 Promise call(List message); |
| 105 | 106 |
| 106 } | 107 } |
| 107 | 108 |
| 108 | 109 |
| 109 class ProxyImpl extends ProxyBase implements Proxy { | 110 class ProxyImpl extends ProxyBase implements Proxy { |
| 110 | 111 |
| 111 ProxyImpl.forPort(SendPort port) | 112 ProxyImpl.forPort(SendPort port) |
| 112 : super.forPort(port) { } | 113 : super.forPort(port) { } |
| 113 | 114 |
| 114 ProxyImpl.forIsolate(Isolate isolate) | 115 ProxyImpl.forIsolate(Isolate isolate) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 PromiseProxy(Promise<SendPort> sendCompleter) { | 170 PromiseProxy(Promise<SendPort> sendCompleter) { |
| 170 ReceivePort completer = new ReceivePort.singleShot(); | 171 ReceivePort completer = new ReceivePort.singleShot(); |
| 171 completer.receive((var msg, SendPort _) { | 172 completer.receive((var msg, SendPort _) { |
| 172 complete(msg[0]); | 173 complete(msg[0]); |
| 173 }); | 174 }); |
| 174 sendCompleter.addCompleteHandler((SendPort port) { | 175 sendCompleter.addCompleteHandler((SendPort port) { |
| 175 port.send([completer.toSendPort()], null); | 176 port.send([completer.toSendPort()], null); |
| 176 }); | 177 }); |
| 177 } | 178 } |
| 178 } | 179 } |
| OLD | NEW |