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<T> controller) | 8 _BroadcastStream(_StreamControllerLifecycle<T> controller) |
9 : super(controller); | 9 : super(controller); |
10 | 10 |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 } | 507 } |
508 | 508 |
509 void _callOnCancel() { | 509 void _callOnCancel() { |
510 if (_hasPending) { | 510 if (_hasPending) { |
511 _pending.clear(); | 511 _pending.clear(); |
512 _pending = null; | 512 _pending = null; |
513 } | 513 } |
514 super._callOnCancel(); | 514 super._callOnCancel(); |
515 } | 515 } |
516 } | 516 } |
517 | |
518 // A subscription that never receives any events. | |
519 // It can simulate pauses, but otherwise does nothing. | |
520 class _DoneSubscription<T> implements StreamSubscription<T> { | |
521 int _pauseCount = 0; | |
522 void onData(void handleData(T data)) {} | |
523 void onError(Function handleError) {} | |
524 void onDone(void handleDone()) {} | |
525 void pause([Future resumeSignal]) { | |
526 if (resumeSignal != null) resumeSignal.then(_resume); | |
527 _pauseCount++; | |
528 } | |
529 | |
530 void resume() { | |
531 _resume(null); | |
532 } | |
533 | |
534 void _resume(_) { | |
535 if (_pauseCount > 0) _pauseCount--; | |
536 } | |
537 | |
538 Future cancel() { | |
539 return new _Future.immediate(null); | |
540 } | |
541 | |
542 bool get isPaused => _pauseCount > 0; | |
543 Future<E> asFuture<E>([E value]) => new _Future<E>(); | |
544 } | |
OLD | NEW |