Chromium Code Reviews| 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() { |