| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** Abstract and private interface for a place to put events. */ | 7 /** Abstract and private interface for a place to put events. */ |
| 8 abstract class _EventSink<T> { | 8 abstract class _EventSink<T> { |
| 9 void _add(T data); | 9 void _add(T data); |
| 10 void _addError(Object error, StackTrace stackTrace); | 10 void _addError(Object error, StackTrace stackTrace); |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 assert(_subscription == null); | 989 assert(_subscription == null); |
| 990 var stateData = _stateData; | 990 var stateData = _stateData; |
| 991 if (stateData != null) { | 991 if (stateData != null) { |
| 992 Stream<T> stream = stateData as Object/*=Stream<T>*/; | 992 Stream<T> stream = stateData as Object/*=Stream<T>*/; |
| 993 _subscription = stream.listen(_onData, | 993 _subscription = stream.listen(_onData, |
| 994 onError: _onError, onDone: _onDone, cancelOnError: true); | 994 onError: _onError, onDone: _onDone, cancelOnError: true); |
| 995 var future = new _Future<bool>(); | 995 var future = new _Future<bool>(); |
| 996 _stateData = future; | 996 _stateData = future; |
| 997 return future; | 997 return future; |
| 998 } | 998 } |
| 999 return new _Future<bool>.immediate(false); | 999 return Future._falseFuture; |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 Future cancel() { | 1002 Future cancel() { |
| 1003 StreamSubscription<T> subscription = _subscription; | 1003 StreamSubscription<T> subscription = _subscription; |
| 1004 Object stateData = _stateData; | 1004 Object stateData = _stateData; |
| 1005 _stateData = null; | 1005 _stateData = null; |
| 1006 if (subscription != null) { | 1006 if (subscription != null) { |
| 1007 _subscription = null; | 1007 _subscription = null; |
| 1008 if (!_isPaused) { | 1008 if (!_isPaused) { |
| 1009 _Future<bool> future = stateData as Object/*=_Future<bool>*/; | 1009 _Future<bool> future = stateData as Object/*=_Future<bool>*/; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 | 1042 |
| 1043 /** An empty broadcast stream, sending a done event as soon as possible. */ | 1043 /** An empty broadcast stream, sending a done event as soon as possible. */ |
| 1044 class _EmptyStream<T> extends Stream<T> { | 1044 class _EmptyStream<T> extends Stream<T> { |
| 1045 const _EmptyStream() : super._internal(); | 1045 const _EmptyStream() : super._internal(); |
| 1046 bool get isBroadcast => true; | 1046 bool get isBroadcast => true; |
| 1047 StreamSubscription<T> listen(void onData(T data), | 1047 StreamSubscription<T> listen(void onData(T data), |
| 1048 {Function onError, void onDone(), bool cancelOnError}) { | 1048 {Function onError, void onDone(), bool cancelOnError}) { |
| 1049 return new _DoneStreamSubscription<T>(onDone); | 1049 return new _DoneStreamSubscription<T>(onDone); |
| 1050 } | 1050 } |
| 1051 } | 1051 } |
| OLD | NEW |