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

Unified Diff: sdk/lib/async/stream_controller.dart

Issue 15981003: Make new StreamController().isPaused be true until the first listener arrives. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 | « runtime/bin/socket_patch.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/stream_controller.dart
diff --git a/sdk/lib/async/stream_controller.dart b/sdk/lib/async/stream_controller.dart
index 7c84f619614683a736bcab993e15afa32169b154..a313f2a992df557ac3339f10ecae3c04bcef4b48 100644
--- a/sdk/lib/async/stream_controller.dart
+++ b/sdk/lib/async/stream_controller.dart
@@ -109,7 +109,17 @@ abstract class StreamController<T> implements EventSink<T> {
*/
bool get isClosed;
- /** Whether the subscription is active and paused. */
+ /**
+ * Whether the subscription would need to buffer events.
+ *
+ * This is the case if the controller's stream has a listener and it is
+ * paused, or if it has not received a listener yet. In that case, the
+ * controller is considered paused as well.
+ *
+ * A broadcast stream controller is never considered paused. It always
+ * forwards its events to all uncanceled listeners, if any, and let them
+ * handle their own pausing.
+ */
bool get isPaused;
/** Whether there is a subscriber on the [Stream]. */
@@ -181,7 +191,8 @@ class _StreamControllerImpl<T> implements StreamController<T>,
bool get isClosed => (_state & _STATE_CLOSED) != 0;
- bool get isPaused => _subscription != null && _subscription._isInputPaused;
+ bool get isPaused => hasListener ? _subscription._isInputPaused
+ : !_isCancelled;
bool get hasListener => _subscription != null;
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698