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

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

Issue 902783008: The execution of an async* should only be scheduled when the stream is (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 f964d399789596eb256b995c627161e682491f74..48d4b606e170ae0edc8a730144cefb5a9abc8aa1 100644
--- a/sdk/lib/_internal/compiler/js_lib/js_helper.dart
+++ b/sdk/lib/_internal/compiler/js_lib/js_helper.dart
@@ -3550,26 +3550,26 @@ Function _wrapJsFunctionForThenHelper(dynamic /* js function */ function,
///
/// If [helperCallback] or [errorCallback] throws the error is added to the
/// stream.
-dynamic streamHelper(dynamic object,
+streamHelper(dynamic object,
floitsch 2015/02/10 13:27:50 Apparently this is now a void function. Mark it as
sigurdm 2015/02/10 13:35:52 Done.
dynamic /* js function */ helperCallback,
AsyncStarStreamController controller,
dynamic /* js function */ errorCallback) {
if (helperCallback == null) {
// This happens on return from the async* function.
controller.close();
- return null;
+ return;
}
if (object is IterationMarker) {
if (controller.stopRunning) {
_wrapJsFunctionForStream(errorCallback, controller)();
- return null;
+ return;
}
if (object.state == IterationMarker.YIELD_SINGLE) {
controller.add(object.value);
// If the controller is paused we stop producing more values.
if (controller.isPaused) {
- return null;
+ return;
}
// TODO(sigurdm): We should not suspend here according to the spec.
scheduleMicrotask(() {
@@ -3586,7 +3586,7 @@ dynamic streamHelper(dynamic object,
controller.isAdding = false;
_wrapJsFunctionForStream(helperCallback, controller)(null);
});
- return null;
+ return;
}
}
@@ -3595,6 +3595,9 @@ dynamic streamHelper(dynamic object,
onError: errorCallback == null
? null
: _wrapJsFunctionForStream(errorCallback, controller));
+}
+
+Stream streamOfController(AsyncStarStreamController controller) {
return controller.stream;
}
@@ -3618,6 +3621,14 @@ class AsyncStarStreamController {
AsyncStarStreamController(helperCallback) {
controller = new StreamController(
+ onListen: () {
+ scheduleMicrotask(() => JS('', '#(null)', helperCallback));
+ },
+ onPause: () {
+ if (!isAdding) {
+ streamHelper(null, helperCallback, this, null);
floitsch 2015/02/10 13:27:50 Why do we need to call the streamHelper when we ar
sigurdm 2015/02/10 13:35:52 Yes, this is wrong - we should not do anything onP
+ }
+ },
onResume: () {
if (!isAdding) {
streamHelper(null, helperCallback, this, null);

Powered by Google App Engine
This is Rietveld 408576698