mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 18:31:32 +00:00
e86b08e5bb
If a target `_Future` is chained to another source `_Future`, then it's because the target will complete with the same result as the source future. Instead of keeping both alive with a listener on the source which completes the target, instead the target moves all its listeners to be directly on the source, and keeps a link to the source in case more listeners are added later. The idea is that most futures are unreferenced after they have had their first listener, so the target future has a chance to be GC'ed. If the target future has `.ignore()` called, and has no listener, then the source completing with an error should not cause the error to be uncaught. Without the optimization, the source would have had a listener, and the target would ignore the error. To simulate that, the source now gets a copy of the target's `_ignoreUnhandledErrors` flag. This is still not precisely the same as it would be without the optimization. If *two* target futures are chained to the same source, and only one of targes has `.ignore()` called, then this implementation will make the uncaught error not be reported, where it technically should. (An alternative would be to *not* use chaining for futures with `ignore()` called on them. But those are precisely futures that are likely to be GC'able, because someone has already said that they don't care if the future complete with errors.) Fixes #54943 Bug: https://github.com/dart-lang/sdk/issues/54943 Change-Id: I0dbb4919ce2ea612d66539862fa0eb188aab8287 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352908 Reviewed-by: Slava Egorov <vegorov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com> Reviewed-by: Stephen Adams <sra@google.com> |
||
---|---|---|
.. | ||
async.dart | ||
async_error.dart | ||
async_sources.gni | ||
broadcast_stream_controller.dart | ||
deferred_load.dart | ||
future.dart | ||
future_extensions.dart | ||
future_impl.dart | ||
schedule_microtask.dart | ||
stream.dart | ||
stream_controller.dart | ||
stream_impl.dart | ||
stream_pipe.dart | ||
stream_transformers.dart | ||
timer.dart | ||
zone.dart |