Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: runtime/lib/async_patch.dart

Issue 1683763002: Cancel async generator only when it yields (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/async_patch.dart
diff --git a/runtime/lib/async_patch.dart b/runtime/lib/async_patch.dart
index fdeb5c9ed4188cad3f2f1508265365aa158d01e7..346e50dd7106d389f4397dc71bdaad47ad593d90 100644
--- a/runtime/lib/async_patch.dart
+++ b/runtime/lib/async_patch.dart
@@ -86,7 +86,7 @@ class _AsyncStarStreamController {
scheduleMicrotask(runBody);
}
- // Adds element to steam, returns true if the caller should terminate
+ // Adds element to stream, returns true if the caller should terminate
// execution of the generator.
//
// TODO(hausner): Per spec, the generator should be suspended before
@@ -177,7 +177,12 @@ class _AsyncStarStreamController {
}
if (cancellationCompleter == null) {
cancellationCompleter = new Completer();
- scheduleGenerator();
+ // Only resume the generator if it is suspended at a yield.
+ // Cancellation does not affect an async generator that is
+ // suspended at an await.
+ if (isSuspendedAtYield) {
+ scheduleGenerator();
+ }
}
return cancellationCompleter.future;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698