| 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 class PromiseImpl<T> implements Promise<T> { | 7 class PromiseImpl<T> implements Promise<T> { |
| 8 | 8 |
| 9 // Enumeration of possible states: | 9 // Enumeration of possible states: |
| 10 static final int CREATED = 0; | 10 static final int CREATED = 0; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 addCompleteHandler((val) { | 255 addCompleteHandler((val) { |
| 256 promises.forEach((promise) { | 256 promises.forEach((promise) { |
| 257 if (!promise.isDone()) { | 257 if (!promise.isDone()) { |
| 258 promise.cancel(); | 258 promise.cancel(); |
| 259 } | 259 } |
| 260 }); | 260 }); |
| 261 }); | 261 }); |
| 262 } | 262 } |
| 263 } | 263 } |
| 264 | 264 |
| 265 class ProxyImpl { | 265 class ProxyBase { |
| 266 | 266 |
| 267 ProxyImpl.forPort(SendPort port) { | 267 ProxyBase.forPort(SendPort port) { |
| 268 _promise = new Promise<SendPort>(); | 268 _promise = new Promise<SendPort>(); |
| 269 _promise.complete(port); | 269 _promise.complete(port); |
| 270 } | 270 } |
| 271 | 271 |
| 272 // Construct a proxy for a message reply; see the [Proxy.forReply] | 272 // Construct a proxy for a message reply; see the [Proxy.forReply] |
| 273 // documentation for more details. | 273 // documentation for more details. |
| 274 ProxyImpl.forReply(Promise<SendPort> port) { | 274 ProxyBase.forReply(Promise<SendPort> port) { |
| 275 _promise = port; | 275 _promise = port; |
| 276 } | 276 } |
| 277 | 277 |
| 278 // Note that comparing proxies or using them in maps is illegal | 278 // Note that comparing proxies or using them in maps is illegal |
| 279 // until they complete. | 279 // until they complete. |
| 280 bool operator ==(var other) { | 280 bool operator ==(var other) { |
| 281 return (other is ProxyImpl) && _promise.value == other._promise.value; | 281 return (other is ProxyBase) && _promise.value == other._promise.value; |
| 282 } | 282 } |
| 283 | 283 |
| 284 int hashCode() => _promise.value.hashCode(); | 284 int hashCode() => _promise.value.hashCode(); |
| 285 | 285 |
| 286 // TODO: consider making this extend Promise<SendPort> instead? | 286 // TODO: consider making this extend Promise<SendPort> instead? |
| 287 void addCompleteHandler(void completeHandler()) { | 287 void addCompleteHandler(void completeHandler()) { |
| 288 _promise.addCompleteHandler((_) => completeHandler()); | 288 _promise.addCompleteHandler((_) => completeHandler()); |
| 289 } | 289 } |
| 290 | 290 |
| 291 static ReceivePort register(Dispatcher dispatcher) { | 291 static ReceivePort register(Dispatcher dispatcher) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 } | 370 } |
| 371 } | 371 } |
| 372 return process(marshalled); | 372 return process(marshalled); |
| 373 }).flatten(); | 373 }).flatten(); |
| 374 } | 374 } |
| 375 | 375 |
| 376 Promise<SendPort> _promise; | 376 Promise<SendPort> _promise; |
| 377 static Map<SendPort, Dispatcher> _dispatchers; | 377 static Map<SendPort, Dispatcher> _dispatchers; |
| 378 | 378 |
| 379 } | 379 } |
| OLD | NEW |