| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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); |
| 105 |
| 104 } | 106 } |
| 105 | 107 |
| 106 | 108 |
| 107 class ProxyImpl extends ProxyBase implements Proxy { | 109 class ProxyImpl extends ProxyBase implements Proxy { |
| 108 | 110 |
| 109 ProxyImpl.forPort(SendPort port) | 111 ProxyImpl.forPort(SendPort port) |
| 110 : super.forPort(port) { } | 112 : super.forPort(port) { } |
| 111 | 113 |
| 112 ProxyImpl.forIsolate(Isolate isolate) | 114 ProxyImpl.forIsolate(Isolate isolate) |
| 113 : this._forIsolateWithPromise(isolate, new Promise<SendPort>()); | 115 : this._forIsolateWithPromise(isolate, new Promise<SendPort>()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 PromiseProxy(Promise<SendPort> sendCompleter) { | 169 PromiseProxy(Promise<SendPort> sendCompleter) { |
| 168 ReceivePort completer = new ReceivePort.singleShot(); | 170 ReceivePort completer = new ReceivePort.singleShot(); |
| 169 completer.receive((var msg, SendPort _) { | 171 completer.receive((var msg, SendPort _) { |
| 170 complete(msg[0]); | 172 complete(msg[0]); |
| 171 }); | 173 }); |
| 172 sendCompleter.addCompleteHandler((SendPort port) { | 174 sendCompleter.addCompleteHandler((SendPort port) { |
| 173 port.send([completer.toSendPort()], null); | 175 port.send([completer.toSendPort()], null); |
| 174 }); | 176 }); |
| 175 } | 177 } |
| 176 } | 178 } |
| OLD | NEW |