| 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 * on [Stream], and it must be used carefully to avoid doing so. | 277 * on [Stream], and it must be used carefully to avoid doing so. |
| 278 * | 278 * |
| 279 * The only advantage to using a [SynchronousStreamController] over a | 279 * The only advantage to using a [SynchronousStreamController] over a |
| 280 * normal [StreamController] is the improved latency. | 280 * normal [StreamController] is the improved latency. |
| 281 * Only use the synchronous version if the improvement is significant, | 281 * Only use the synchronous version if the improvement is significant, |
| 282 * and if its use is safe. Otherwise just use a normal stream controller, | 282 * and if its use is safe. Otherwise just use a normal stream controller, |
| 283 * which will always have the correct behavior for a [Stream], and won't | 283 * which will always have the correct behavior for a [Stream], and won't |
| 284 * accidentally break other code. | 284 * accidentally break other code. |
| 285 * | 285 * |
| 286 * Adding events to a synchronous controller should only happen as the | 286 * Adding events to a synchronous controller should only happen as the |
| 287 * very last part of a the handling of the original event. | 287 * very last part of the handling of the original event. |
| 288 * At that point, adding an event to the stream is equivalent to | 288 * At that point, adding an event to the stream is equivalent to |
| 289 * returning to the event loop and adding the event in the next microtask. | 289 * returning to the event loop and adding the event in the next microtask. |
| 290 * | 290 * |
| 291 * Each listener callback will be run as if it was a top-level event | 291 * Each listener callback will be run as if it was a top-level event |
| 292 * or microtask. This means that if it throws, the error will be reported as | 292 * or microtask. This means that if it throws, the error will be reported as |
| 293 * uncaught as soon as possible. | 293 * uncaught as soon as possible. |
| 294 * This is one reason to add the event as the last thing in the original event | 294 * This is one reason to add the event as the last thing in the original event |
| 295 * handler - any action done after adding the event will delay the report of | 295 * handler - any action done after adding the event will delay the report of |
| 296 * errors in the event listener callbacks. | 296 * errors in the event listener callbacks. |
| 297 * | 297 * |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 var varData; | 925 var varData; |
| 926 | 926 |
| 927 _StreamControllerAddStreamState(_StreamController<T> controller, this.varData, | 927 _StreamControllerAddStreamState(_StreamController<T> controller, this.varData, |
| 928 Stream source, bool cancelOnError) | 928 Stream source, bool cancelOnError) |
| 929 : super(controller, source, cancelOnError) { | 929 : super(controller, source, cancelOnError) { |
| 930 if (controller.isPaused) { | 930 if (controller.isPaused) { |
| 931 addSubscription.pause(); | 931 addSubscription.pause(); |
| 932 } | 932 } |
| 933 } | 933 } |
| 934 } | 934 } |
| OLD | NEW |