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

Side by Side Diff: sdk/lib/async/merge_stream.dart

Issue 11740027: Rename unsubscribe to cancel. (Closed) Base URL: https://dart.googlecode.com/svn/experimental/lib_v2/dart
Patch Set: Address comments. Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/async/stream.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // part of dart.async; 5 // part of dart.async;
6 6
7 class _SupercedeEntry<T> { 7 class _SupercedeEntry<T> {
8 final SupercedeStream stream; 8 final SupercedeStream stream;
9 Stream<T> source; 9 Stream<T> source;
10 StreamSubscription subscription = null; 10 StreamSubscription subscription = null;
(...skipping 22 matching lines...) Expand all
33 void start() { 33 void start() {
34 assert(subscription == null); 34 assert(subscription == null);
35 if (!isDone) { 35 if (!isDone) {
36 subscription = 36 subscription =
37 source.listen(onData, onError: onError, onDone: onDone); 37 source.listen(onData, onError: onError, onDone: onDone);
38 } 38 }
39 } 39 }
40 40
41 void stop() { 41 void stop() {
42 if (!isDone) { 42 if (!isDone) {
43 subscription.unsubscribe(); 43 subscription.cancel();
44 subscription = null; 44 subscription = null;
45 } 45 }
46 } 46 }
47 47
48 void pause() { 48 void pause() {
49 if (!isDone) subscription.pause(); 49 if (!isDone) subscription.pause();
50 } 50 }
51 51
52 void resume() { 52 void resume() {
53 if (!isDone) subscription.resume(); 53 if (!isDone) subscription.resume();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 final CyclicScheduleStream stream; 157 final CyclicScheduleStream stream;
158 /** A single source stream for the [CyclicScheduleStream]. */ 158 /** A single source stream for the [CyclicScheduleStream]. */
159 Stream source; 159 Stream source;
160 /** The active subscription, if any. */ 160 /** The active subscription, if any. */
161 StreamSubscription subscription = null; 161 StreamSubscription subscription = null;
162 /** Next entry in a linked list of entries. */ 162 /** Next entry in a linked list of entries. */
163 _CycleEntry next; 163 _CycleEntry next;
164 164
165 _CycleEntry(this.stream, this.source); 165 _CycleEntry(this.stream, this.source);
166 166
167 void unsubscribe() { 167 void cancel() {
168 // This method may be called event if this entry has never been activated. 168 // This method may be called event if this entry has never been activated.
169 if (subscription != null) { 169 if (subscription != null) {
170 subscription.unsubscribe(); 170 subscription.cancel();
171 subscription = null; 171 subscription = null;
172 } 172 }
173 } 173 }
174 174
175 void pause() { 175 void pause() {
176 ensureSubscribed(); 176 ensureSubscribed();
177 if (!subscription.isPaused) { 177 if (!subscription.isPaused) {
178 subscription.pause(); 178 subscription.pause();
179 } 179 }
180 } 180 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 if (_hasSubscribers) { 235 if (_hasSubscribers) {
236 _currentEntry.activate(); 236 _currentEntry.activate();
237 for (_CycleEntry entry = _currentEntry.next; 237 for (_CycleEntry entry = _currentEntry.next;
238 entry != null; 238 entry != null;
239 entry = entry.next) { 239 entry = entry.next) {
240 entry.pause(); 240 entry.pause();
241 } 241 }
242 return; 242 return;
243 } 243 }
244 for (_CycleEntry entry = _currentEntry; entry != null; entry = entry.next) { 244 for (_CycleEntry entry = _currentEntry; entry != null; entry = entry.next) {
245 entry.unsubscribe(); 245 entry.cancel();
246 } 246 }
247 } 247 }
248 248
249 void _onPauseStateChange() { 249 void _onPauseStateChange() {
250 if (_isPaused) { 250 if (_isPaused) {
251 _currentEntry.pause(); 251 _currentEntry.pause();
252 } else { 252 } else {
253 _currentEntry.activate(); 253 _currentEntry.activate();
254 } 254 }
255 } 255 }
(...skipping 17 matching lines...) Expand all
273 if (_currentEntry.next == null) { 273 if (_currentEntry.next == null) {
274 _close(); 274 _close();
275 _currentEntry = _lastEntry = null; 275 _currentEntry = _lastEntry = null;
276 } else { 276 } else {
277 // Remove the current entry from the list now that it's complete. 277 // Remove the current entry from the list now that it's complete.
278 _currentEntry = _currentEntry.next; 278 _currentEntry = _currentEntry.next;
279 _currentEntry.activate(); 279 _currentEntry.activate();
280 } 280 }
281 } 281 }
282 } 282 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/async/stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698