| 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 // States shared by single/multi stream implementations. | 7 // States shared by single/multi stream implementations. |
| 8 | 8 |
| 9 /// Initial and default state where the stream can receive and send events. | 9 /// Initial and default state where the stream can receive and send events. |
| 10 const int _STREAM_OPEN = 0; | 10 const int _STREAM_OPEN = 0; |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 class _MultiStreamImpl<T> extends _StreamImpl<T> | 537 class _MultiStreamImpl<T> extends _StreamImpl<T> |
| 538 implements _InternalLinkList { | 538 implements _InternalLinkList { |
| 539 // Link list implementation (mixin when possible). | 539 // Link list implementation (mixin when possible). |
| 540 _InternalLink _nextLink; | 540 _InternalLink _nextLink; |
| 541 _InternalLink _previousLink; | 541 _InternalLink _previousLink; |
| 542 | 542 |
| 543 _MultiStreamImpl() { | 543 _MultiStreamImpl() { |
| 544 _nextLink = _previousLink = this; | 544 _nextLink = _previousLink = this; |
| 545 } | 545 } |
| 546 | 546 |
| 547 bool get isSingleSubscription => false; | 547 bool get isBroadcast => true; |
| 548 | 548 |
| 549 Stream<T> asMultiSubscriberStream() => this; | 549 Stream<T> asBroadcastStream() => this; |
| 550 | 550 |
| 551 // ------------------------------------------------------------------ | 551 // ------------------------------------------------------------------ |
| 552 // Helper functions that can be overridden in subclasses. | 552 // Helper functions that can be overridden in subclasses. |
| 553 | 553 |
| 554 /** Whether there are currently any subscribers on this [Stream]. */ | 554 /** Whether there are currently any subscribers on this [Stream]. */ |
| 555 bool get _hasSubscribers => !_InternalLinkList.isEmpty(this); | 555 bool get _hasSubscribers => !_InternalLinkList.isEmpty(this); |
| 556 | 556 |
| 557 /** | 557 /** |
| 558 * Create the new subscription object. | 558 * Create the new subscription object. |
| 559 */ | 559 */ |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 onError: this._signalError, | 1159 onError: this._signalError, |
| 1160 onDone: this._close); | 1160 onDone: this._close); |
| 1161 } else { | 1161 } else { |
| 1162 // TODO(lrn): Check why this can happen. | 1162 // TODO(lrn): Check why this can happen. |
| 1163 if (_subscription == null) return; | 1163 if (_subscription == null) return; |
| 1164 _subscription.cancel(); | 1164 _subscription.cancel(); |
| 1165 _subscription = null; | 1165 _subscription = null; |
| 1166 } | 1166 } |
| 1167 } | 1167 } |
| 1168 } | 1168 } |
| OLD | NEW |