OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.async; | 5 part of dart.async; |
6 | 6 |
7 // ------------------------------------------------------------------- | 7 // ------------------------------------------------------------------- |
8 // Core Stream types | 8 // Core Stream types |
9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
10 | 10 |
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 if (onTimeout == null) { | 1307 if (onTimeout == null) { |
1308 timeout = () { | 1308 timeout = () { |
1309 controller.addError( | 1309 controller.addError( |
1310 new TimeoutException("No stream event", timeLimit), null); | 1310 new TimeoutException("No stream event", timeLimit), null); |
1311 }; | 1311 }; |
1312 } else { | 1312 } else { |
1313 // TODO(floitsch): the return type should be 'void', and the type | 1313 // TODO(floitsch): the return type should be 'void', and the type |
1314 // should be inferred. | 1314 // should be inferred. |
1315 var registeredOnTimeout = | 1315 var registeredOnTimeout = |
1316 zone.registerUnaryCallback<dynamic, EventSink<T>>(onTimeout); | 1316 zone.registerUnaryCallback<dynamic, EventSink<T>>(onTimeout); |
1317 var wrapper = new _ControllerEventSinkWrapper<T>(null); | 1317 _ControllerEventSinkWrapper wrapper = |
| 1318 new _ControllerEventSinkWrapper(null); |
1318 timeout = () { | 1319 timeout = () { |
1319 wrapper._sink = controller; // Only valid during call. | 1320 wrapper._sink = controller; // Only valid during call. |
1320 zone.runUnaryGuarded(registeredOnTimeout, wrapper); | 1321 zone.runUnaryGuarded(registeredOnTimeout, wrapper); |
1321 wrapper._sink = null; | 1322 wrapper._sink = null; |
1322 }; | 1323 }; |
1323 } | 1324 } |
1324 | 1325 |
1325 subscription = this.listen(onData, onError: onError, onDone: onDone); | 1326 subscription = this.listen(onData, onError: onError, onDone: onDone); |
1326 timer = zone.createTimer(timeLimit, timeout); | 1327 timer = zone.createTimer(timeLimit, timeout); |
1327 } | 1328 } |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1788 } | 1789 } |
1789 | 1790 |
1790 void addError(error, [StackTrace stackTrace]) { | 1791 void addError(error, [StackTrace stackTrace]) { |
1791 _sink.addError(error, stackTrace); | 1792 _sink.addError(error, stackTrace); |
1792 } | 1793 } |
1793 | 1794 |
1794 void close() { | 1795 void close() { |
1795 _sink.close(); | 1796 _sink.close(); |
1796 } | 1797 } |
1797 } | 1798 } |
OLD | NEW |