| 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 class _BroadcastStream<T> extends _ControllerStream<T> { | 7 class _BroadcastStream<T> extends _ControllerStream<T> { |
| 8 _BroadcastStream(_StreamControllerLifecycle controller) : super(controller); | 8 _BroadcastStream(_StreamControllerLifecycle controller) : super(controller); |
| 9 | 9 |
| 10 bool get isBroadcast => true; | 10 bool get isBroadcast => true; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 bool _expectsEvent(int eventId) => | 39 bool _expectsEvent(int eventId) => |
| 40 (_eventState & _STATE_EVENT_ID) == eventId; | 40 (_eventState & _STATE_EVENT_ID) == eventId; |
| 41 | 41 |
| 42 void _toggleEventId() { | 42 void _toggleEventId() { |
| 43 _eventState ^= _STATE_EVENT_ID; | 43 _eventState ^= _STATE_EVENT_ID; |
| 44 } | 44 } |
| 45 | 45 |
| 46 bool get _isFiring => (_eventState & _STATE_FIRING) != 0; | 46 bool get _isFiring => (_eventState & _STATE_FIRING) != 0; |
| 47 | 47 |
| 48 bool _setRemoveAfterFiring() { | 48 void _setRemoveAfterFiring() { |
| 49 assert(_isFiring); | 49 assert(_isFiring); |
| 50 _eventState |= _STATE_REMOVE_AFTER_FIRING; | 50 _eventState |= _STATE_REMOVE_AFTER_FIRING; |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool get _removeAfterFiring => | 53 bool get _removeAfterFiring => |
| 54 (_eventState & _STATE_REMOVE_AFTER_FIRING) != 0; | 54 (_eventState & _STATE_REMOVE_AFTER_FIRING) != 0; |
| 55 | 55 |
| 56 // The controller._recordPause doesn't do anything for a broadcast controller, | 56 // The controller._recordPause doesn't do anything for a broadcast controller, |
| 57 // so we don't bother calling it. | 57 // so we don't bother calling it. |
| 58 void _onPause() { } | 58 void _onPause() { } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 subscription._setRemoveAfterFiring(); | 200 subscription._setRemoveAfterFiring(); |
| 201 } else { | 201 } else { |
| 202 assert(!identical(subscription._next, subscription)); | 202 assert(!identical(subscription._next, subscription)); |
| 203 _removeListener(subscription); | 203 _removeListener(subscription); |
| 204 // If we are currently firing an event, the empty-check is performed at | 204 // If we are currently firing an event, the empty-check is performed at |
| 205 // the end of the listener loop instead of here. | 205 // the end of the listener loop instead of here. |
| 206 if (!_isFiring && _isEmpty) { | 206 if (!_isFiring && _isEmpty) { |
| 207 _callOnCancel(); | 207 _callOnCancel(); |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 return null; |
| 210 } | 211 } |
| 211 | 212 |
| 212 void _recordPause(StreamSubscription<T> subscription) {} | 213 void _recordPause(StreamSubscription<T> subscription) {} |
| 213 void _recordResume(StreamSubscription<T> subscription) {} | 214 void _recordResume(StreamSubscription<T> subscription) {} |
| 214 | 215 |
| 215 // EventSink interface. | 216 // EventSink interface. |
| 216 | 217 |
| 217 Error _addEventError() { | 218 Error _addEventError() { |
| 218 if (isClosed) { | 219 if (isClosed) { |
| 219 return new StateError("Cannot add new events after calling close"); | 220 return new StateError("Cannot add new events after calling close"); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 _pauseCount++; | 488 _pauseCount++; |
| 488 } | 489 } |
| 489 void resume() { _resume(null); } | 490 void resume() { _resume(null); } |
| 490 void _resume(_) { | 491 void _resume(_) { |
| 491 if (_pauseCount > 0) _pauseCount--; | 492 if (_pauseCount > 0) _pauseCount--; |
| 492 } | 493 } |
| 493 Future cancel() { return new _Future.immediate(null); } | 494 Future cancel() { return new _Future.immediate(null); } |
| 494 bool get isPaused => _pauseCount > 0; | 495 bool get isPaused => _pauseCount > 0; |
| 495 Future asFuture([Object value]) => new _Future(); | 496 Future asFuture([Object value]) => new _Future(); |
| 496 } | 497 } |
| OLD | NEW |