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

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;
asyncStarBody();
}
@@ -65,12 +67,14 @@
// if (controller.isCanelled) return;
Ivan Posva 2015/04/08 21:49:55 Cannelloni?
hausner 2015/04/08 22:12:44 Basta.
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