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

Unified Diff: runtime/lib/core_patch.dart

Issue 1073623002: Fix spurious resume when awaiting future in async* code (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 8 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 | runtime/vm/parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/core_patch.dart
===================================================================
--- runtime/lib/core_patch.dart (revision 44981)
+++ runtime/lib/core_patch.dart (working copy)
@@ -36,12 +36,14 @@
bool isAdding = false;
bool onListenReceived = false;
bool isScheduled = false;
+ bool isSuspendedAtYield = false;
Completer cancellationCompleter = null;
Stream get stream => controller.stream;
void runBody() {
isScheduled = false;
+ isSuspendedAtYield = false;
Lasse Reichstein Nielsen 2015/04/09 06:35:30 If I understand this correctly, your possible stat
hausner 2015/04/09 17:10:19 I agree that the code and comments could be cleare
asyncStarBody();
}
@@ -62,15 +64,17 @@
// The generator would translate a 'yield e' statement to
// controller.add(e);
// suspend;
- // if (controller.isCanelled) return;
+ // if (controller.isCancelled) return;
bool add(event) {
if (!onListenReceived) _fatal("yield before stream is listened to!");
+ if (isSuspendedAtYield) _fatal("unexpected yield");
// If stream is cancelled, tell caller to exit the async generator.
if (!controller.hasListener) {
return true;
}
controller.add(event);
scheduleGenerator();
+ isSuspendedAtYield = true;
return false;
}
@@ -131,7 +135,9 @@
}
onResume() {
- scheduleGenerator();
+ if (isSuspendedAtYield) {
+ scheduleGenerator();
+ }
}
onCancel() {
« no previous file with comments | « no previous file | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698