| 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 void add(T value) { | 393 void add(T value) { |
| 394 if (!_mayAddEvent) throw _badEventState(); | 394 if (!_mayAddEvent) throw _badEventState(); |
| 395 _add(value); | 395 _add(value); |
| 396 } | 396 } |
| 397 | 397 |
| 398 /** | 398 /** |
| 399 * Send or enqueue an error event. | 399 * Send or enqueue an error event. |
| 400 */ | 400 */ |
| 401 void addError(Object error, [StackTrace stackTrace]) { | 401 void addError(Object error, [StackTrace stackTrace]) { |
| 402 if (!_mayAddEvent) throw _badEventState(); | 402 if (!_mayAddEvent) throw _badEventState(); |
| 403 if (stackTrace != null) { | |
| 404 // Force stack trace overwrite. Even if the error already contained | |
| 405 // a stack trace. | |
| 406 _attachStackTrace(error, stackTrace); | |
| 407 } | |
| 408 _addError(error, stackTrace); | 403 _addError(error, stackTrace); |
| 409 } | 404 } |
| 410 | 405 |
| 411 /** | 406 /** |
| 412 * Closes this controller. | 407 * Closes this controller. |
| 413 * | 408 * |
| 414 * After closing, no further events may be added using [add] or [addError]. | 409 * After closing, no further events may be added using [add] or [addError]. |
| 415 * | 410 * |
| 416 * You are allowed to close the controller more than once, but only the first | 411 * You are allowed to close the controller more than once, but only the first |
| 417 * call has any effect. | 412 * call has any effect. |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 | 597 |
| 603 typedef _NotificationHandler(); | 598 typedef _NotificationHandler(); |
| 604 | 599 |
| 605 Future _runGuarded(_NotificationHandler notificationHandler) { | 600 Future _runGuarded(_NotificationHandler notificationHandler) { |
| 606 if (notificationHandler == null) return null; | 601 if (notificationHandler == null) return null; |
| 607 try { | 602 try { |
| 608 var result = notificationHandler(); | 603 var result = notificationHandler(); |
| 609 if (result is Future) return result; | 604 if (result is Future) return result; |
| 610 return null; | 605 return null; |
| 611 } catch (e, s) { | 606 } catch (e, s) { |
| 612 Zone.current.handleUncaughtError(_asyncError(e, s), s); | 607 Zone.current.handleUncaughtError(e, s); |
| 613 } | 608 } |
| 614 } | 609 } |
| 615 | 610 |
| 616 class _ControllerStream<T> extends _StreamImpl<T> { | 611 class _ControllerStream<T> extends _StreamImpl<T> { |
| 617 _StreamControllerLifecycle<T> _controller; | 612 _StreamControllerLifecycle<T> _controller; |
| 618 | 613 |
| 619 _ControllerStream(this._controller); | 614 _ControllerStream(this._controller); |
| 620 | 615 |
| 621 StreamSubscription<T> _createSubscription(bool cancelOnError) => | 616 StreamSubscription<T> _createSubscription(bool cancelOnError) => |
| 622 _controller._subscribe(cancelOnError); | 617 _controller._subscribe(cancelOnError); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 _StreamControllerAddStreamState(_StreamController controller, | 715 _StreamControllerAddStreamState(_StreamController controller, |
| 721 this.varData, | 716 this.varData, |
| 722 Stream source, | 717 Stream source, |
| 723 bool cancelOnError) | 718 bool cancelOnError) |
| 724 : super(controller, source, cancelOnError) { | 719 : super(controller, source, cancelOnError) { |
| 725 if (controller.isPaused) { | 720 if (controller.isPaused) { |
| 726 addSubscription.pause(); | 721 addSubscription.pause(); |
| 727 } | 722 } |
| 728 } | 723 } |
| 729 } | 724 } |
| OLD | NEW |