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; |
|
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() { |