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

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

Issue 839323003: Implementation of async-await transformation on js ast. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Implement new ssa-nodes in ssa-tracer. 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 unified diff | Download patch | Annotate | Revision Log
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 /** Abstract and private interface for a place to put events. */ 7 /** Abstract and private interface for a place to put events. */
8 abstract class _EventSink<T> { 8 abstract class _EventSink<T> {
9 void _add(T data); 9 void _add(T data);
10 void _addError(Object error, StackTrace stackTrace); 10 void _addError(Object error, StackTrace stackTrace);
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 1029
1030 Future cancel() { 1030 Future cancel() {
1031 StreamSubscription subscription = _subscription; 1031 StreamSubscription subscription = _subscription;
1032 if (_state == _STATE_MOVING) { 1032 if (_state == _STATE_MOVING) {
1033 _Future<bool> hasNext = _futureOrPrefetch; 1033 _Future<bool> hasNext = _futureOrPrefetch;
1034 _clear(); 1034 _clear();
1035 hasNext._complete(false); 1035 hasNext._complete(false);
1036 } else { 1036 } else {
1037 _clear(); 1037 _clear();
1038 } 1038 }
1039 return subscription.cancel(); 1039 // If the stream is done, the subscription will have been cleared.
1040 return subscription == null
1041 ? new _Future<Null>.immediate(null)
floitsch 2015/02/02 22:00:12 This does not belong into this CL. Create a new C
sigurdm 2015/02/03 16:59:33 Ok.
1042 : subscription.cancel();
1040 } 1043 }
1041 1044
1042 void _onData(T data) { 1045 void _onData(T data) {
1043 if (_state == _STATE_MOVING) { 1046 if (_state == _STATE_MOVING) {
1044 _current = data; 1047 _current = data;
1045 _Future<bool> hasNext = _futureOrPrefetch; 1048 _Future<bool> hasNext = _futureOrPrefetch;
1046 _futureOrPrefetch = null; 1049 _futureOrPrefetch = null;
1047 _state = _STATE_FOUND; 1050 _state = _STATE_FOUND;
1048 hasNext._complete(true); 1051 hasNext._complete(true);
1049 return; 1052 return;
(...skipping 23 matching lines...) Expand all
1073 _Future<bool> hasNext = _futureOrPrefetch; 1076 _Future<bool> hasNext = _futureOrPrefetch;
1074 _clear(); 1077 _clear();
1075 hasNext._complete(false); 1078 hasNext._complete(false);
1076 return; 1079 return;
1077 } 1080 }
1078 _subscription.pause(); 1081 _subscription.pause();
1079 _futureOrPrefetch = null; 1082 _futureOrPrefetch = null;
1080 _state = _STATE_EXTRA_DONE; 1083 _state = _STATE_EXTRA_DONE;
1081 } 1084 }
1082 } 1085 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698