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

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

Issue 12545056: Make stream subscription more lax wrt. calling methods on it after it's completed. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | « no previous file | sdk/lib/async/stream_pipe.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/stream_impl.dart
diff --git a/sdk/lib/async/stream_impl.dart b/sdk/lib/async/stream_impl.dart
index 1563abdda558d004f36ac2ba8fe2aed65ce2e58a..e3ebd367c89591497d6919a6df067b94281b8ffc 100644
--- a/sdk/lib/async/stream_impl.dart
+++ b/sdk/lib/async/stream_impl.dart
@@ -942,17 +942,17 @@ class _StreamSubscriptionImpl<T> extends _StreamListener<T>
}
void cancel() {
+ if (!_isSubscribed) return;
_source._cancel(this);
}
void pause([Future resumeSignal]) {
+ if (!_isSubscribed) return;
_source._pause(this, resumeSignal);
}
void resume() {
- if (!isPaused) {
- throw new StateError("Resuming unpaused subscription");
- }
+ if (!_isSubscribed || !isPaused) return;
_source._resume(this, false);
}
}
@@ -1270,9 +1270,7 @@ class _DoneSubscription<T> implements StreamSubscription<T> {
}
void pause([Future signal]) {
- if (_isComplete) {
- throw new StateError("Subscription has been canceled.");
- }
+ if (_isComplete) return;
if (_timer != null) {
_timer.cancel();
_timer = null;
@@ -1282,9 +1280,7 @@ class _DoneSubscription<T> implements StreamSubscription<T> {
}
void resume() {
- if (_isComplete) {
- throw new StateError("Subscription has been canceled.");
- }
+ if (_isComplete) return;
if (_pauseCount == 0) return;
_pauseCount--;
if (_pauseCount == 0) {
@@ -1295,9 +1291,7 @@ class _DoneSubscription<T> implements StreamSubscription<T> {
bool get isPaused => _pauseCount > 0;
void cancel() {
- if (_isComplete) {
- throw new StateError("Subscription has been canceled.");
- }
+ if (_isComplete) return;
if (_timer != null) {
_timer.cancel();
_timer = null;
« no previous file with comments | « no previous file | sdk/lib/async/stream_pipe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698