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

Unified Diff: sdk/lib/_internal/compiler/js_lib/js_helper.dart

Issue 1070733002: Dart2js async* functions only resume execution of the body when suspended on yield. (Closed) Base URL: https://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
Index: sdk/lib/_internal/compiler/js_lib/js_helper.dart
diff --git a/sdk/lib/_internal/compiler/js_lib/js_helper.dart b/sdk/lib/_internal/compiler/js_lib/js_helper.dart
index 163833b6ffadbac2da7a19366980a6bcf9041896..d2b6795ce42eea337c8c28328a3af380b530af83 100644
--- a/sdk/lib/_internal/compiler/js_lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/js_lib/js_helper.dart
@@ -3741,6 +3741,7 @@ void asyncStarHelper(dynamic object,
return;
}
if (object.state == IterationMarker.YIELD_SINGLE) {
+ controller.isWaitingForYield = true;
controller.add(object.value);
// If the controller is paused we stop producing more values.
if (controller.isPaused) {
@@ -3748,6 +3749,7 @@ void asyncStarHelper(dynamic object,
}
// TODO(sigurdm): We should not suspend here according to the spec.
Lasse Reichstein Nielsen 2015/04/08 14:12:14 Isn't the spec allowing you to do so, but not requ
sigurdm 2015/04/09 11:24:08 Yes I think so - this is an outdated comment. Remo
scheduleMicrotask(() {
+ controller.isWaitingForYield = false;
Lasse Reichstein Nielsen 2015/04/08 14:12:15 I think this line should be moved outside of the s
sigurdm 2015/04/09 11:24:08 Done.
_wrapJsFunctionForAsync(bodyFunctionOrErrorCode,
async_error_codes.SUCCESS)
(null);
@@ -3796,6 +3798,8 @@ class AsyncStarStreamController {
bool get isCanceled => cancelationCompleter != null;
bool isAdding = false;
bool isPaused = false;
+ bool isWaitingForYield = false;
floitsch 2015/04/08 14:01:25 isAtYield ? Add comment what exactly this means.
sigurdm 2015/04/08 14:07:40 Done.
Lasse Reichstein Nielsen 2015/04/08 14:12:14 Consider documenting these fields, preferably by d
sigurdm 2015/04/09 11:24:08 Good advice! I realized I can leave out `isAdding`
+
add(event) => controller.add(event);
addStream(Stream stream) {
return controller.addStream(stream, cancelOnError: false);
@@ -3807,8 +3811,8 @@ class AsyncStarStreamController {
controller = new StreamController(
onListen: () {
scheduleMicrotask(() {
- Function wrapped = _wrapJsFunctionForAsync(body,
- async_error_codes.SUCCESS);
+ Function wrapped =
+ _wrapJsFunctionForAsync(body, async_error_codes.SUCCESS);
wrapped(null);
});
},
@@ -3816,7 +3820,7 @@ class AsyncStarStreamController {
isPaused = true;
}, onResume: () {
isPaused = false;
- if (!isAdding) {
+ if (!isAdding && isWaitingForYield) {
Lasse Reichstein Nielsen 2015/04/08 14:12:15 I don't think this is safe enough. If the stream
Lasse Reichstein Nielsen 2015/04/08 14:12:15 Maybe name it "isWaitingForResume"? You have alrea
sigurdm 2015/04/09 11:24:08 It is now isSuspended
asyncStarHelper(null, body, this);
}
}, onCancel: () {

Powered by Google App Engine
This is Rietveld 408576698