| 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 // ------------------------------------------------------------------- | 7 // ------------------------------------------------------------------- |
| 8 // Controller for creating and adding events to a stream. | 8 // Controller for creating and adding events to a stream. |
| 9 // ------------------------------------------------------------------- | 9 // ------------------------------------------------------------------- |
| 10 | 10 |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 void add(T value) { | 370 void add(T value) { |
| 371 if (!_mayAddEvent) throw _badEventState(); | 371 if (!_mayAddEvent) throw _badEventState(); |
| 372 _add(value); | 372 _add(value); |
| 373 } | 373 } |
| 374 | 374 |
| 375 /** | 375 /** |
| 376 * Send or enqueue an error event. | 376 * Send or enqueue an error event. |
| 377 */ | 377 */ |
| 378 void addError(Object error, [StackTrace stackTrace]) { | 378 void addError(Object error, [StackTrace stackTrace]) { |
| 379 if (!_mayAddEvent) throw _badEventState(); | 379 if (!_mayAddEvent) throw _badEventState(); |
| 380 if (stackTrace != null) { | |
| 381 // Force stack trace overwrite. Even if the error already contained | |
| 382 // a stack trace. | |
| 383 _attachStackTrace(error, stackTrace); | |
| 384 } | |
| 385 _addError(error, stackTrace); | 380 _addError(error, stackTrace); |
| 386 } | 381 } |
| 387 | 382 |
| 388 /** | 383 /** |
| 389 * Closes this controller. | 384 * Closes this controller. |
| 390 * | 385 * |
| 391 * After closing, no further events may be added using [add] or [addError]. | 386 * After closing, no further events may be added using [add] or [addError]. |
| 392 * | 387 * |
| 393 * You are allowed to close the controller more than once, but only the first | 388 * You are allowed to close the controller more than once, but only the first |
| 394 * call has any effect. | 389 * call has any effect. |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 | 573 |
| 579 typedef _NotificationHandler(); | 574 typedef _NotificationHandler(); |
| 580 | 575 |
| 581 Future _runGuarded(_NotificationHandler notificationHandler) { | 576 Future _runGuarded(_NotificationHandler notificationHandler) { |
| 582 if (notificationHandler == null) return null; | 577 if (notificationHandler == null) return null; |
| 583 try { | 578 try { |
| 584 var result = notificationHandler(); | 579 var result = notificationHandler(); |
| 585 if (result is Future) return result; | 580 if (result is Future) return result; |
| 586 return null; | 581 return null; |
| 587 } catch (e, s) { | 582 } catch (e, s) { |
| 588 Zone.current.handleUncaughtError(_asyncError(e, s), s); | 583 Zone.current.handleUncaughtError(e, s); |
| 589 } | 584 } |
| 590 } | 585 } |
| 591 | 586 |
| 592 class _ControllerStream<T> extends _StreamImpl<T> { | 587 class _ControllerStream<T> extends _StreamImpl<T> { |
| 593 _StreamControllerLifecycle<T> _controller; | 588 _StreamControllerLifecycle<T> _controller; |
| 594 | 589 |
| 595 _ControllerStream(this._controller); | 590 _ControllerStream(this._controller); |
| 596 | 591 |
| 597 StreamSubscription<T> _createSubscription(bool cancelOnError) => | 592 StreamSubscription<T> _createSubscription(bool cancelOnError) => |
| 598 _controller._subscribe(cancelOnError); | 593 _controller._subscribe(cancelOnError); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 var varData; | 681 var varData; |
| 687 | 682 |
| 688 _StreamControllerAddStreamState(_StreamController controller, | 683 _StreamControllerAddStreamState(_StreamController controller, |
| 689 this.varData, | 684 this.varData, |
| 690 Stream source) : super(controller, source) { | 685 Stream source) : super(controller, source) { |
| 691 if (controller.isPaused) { | 686 if (controller.isPaused) { |
| 692 addSubscription.pause(); | 687 addSubscription.pause(); |
| 693 } | 688 } |
| 694 } | 689 } |
| 695 } | 690 } |
| OLD | NEW |