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

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

Issue 14886015: Use runAsync for Futures. (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 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 deprecatedFutureValue(_FutureImpl future) => 7 deprecatedFutureValue(_FutureImpl future) =>
8 future._isComplete ? future._resultOrListeners : null; 8 future._isComplete ? future._resultOrListeners : null;
9 9
10 abstract class _Completer<T> implements Completer<T> { 10 abstract class _Completer<T> implements Completer<T> {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 listeners = listener._nextListener; 210 listeners = listener._nextListener;
211 listener._nextListener = null; 211 listener._nextListener = null;
212 listener._sendError(error); 212 listener._sendError(error);
213 } while (listeners != null); 213 } while (listeners != null);
214 } 214 }
215 215
216 void _scheduleUnhandledError() { 216 void _scheduleUnhandledError() {
217 _state |= _UNHANDLED_ERROR; 217 _state |= _UNHANDLED_ERROR;
218 // Wait for the rest of the current event's duration to see 218 // Wait for the rest of the current event's duration to see
219 // if a subscriber is added to handle the error. 219 // if a subscriber is added to handle the error.
220 Timer.run(() { 220 runAsync(() {
221 if (_hasUnhandledError) { 221 if (_hasUnhandledError) {
222 // No error handler has been added since the error was set. 222 // No error handler has been added since the error was set.
223 _clearUnhandledError(); 223 _clearUnhandledError();
224 var error = _resultOrListeners; 224 var error = _resultOrListeners;
225 print("Uncaught Error: ${error}"); 225 print("Uncaught Error: ${error}");
226 var trace = getAttachedStackTrace(error); 226 var trace = getAttachedStackTrace(error);
227 if (trace != null) { 227 if (trace != null) {
228 print("Stack Trace:\n$trace\n"); 228 print("Stack Trace:\n$trace\n");
229 } 229 }
230 throw error; 230 throw error;
231 } 231 }
232 }); 232 });
233 } 233 }
234 234
235 void _addListener(_FutureListener listener) { 235 void _addListener(_FutureListener listener) {
236 if (_isComplete) { 236 if (_isComplete) {
237 _clearUnhandledError(); 237 _clearUnhandledError();
238 // Handle late listeners asynchronously. 238 // Handle late listeners asynchronously.
239 Timer.run(() { 239 runAsync(() {
240 if (_hasValue) { 240 if (_hasValue) {
241 T value = _resultOrListeners; 241 T value = _resultOrListeners;
242 listener._sendValue(value); 242 listener._sendValue(value);
243 } else { 243 } else {
244 assert(_hasError); 244 assert(_hasError);
245 listener._sendError(_resultOrListeners); 245 listener._sendError(_resultOrListeners);
246 } 246 }
247 }); 247 });
248 } else { 248 } else {
249 assert(!_isComplete); 249 assert(!_isComplete);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 Future catchError(function(error), {bool test(var error)}) { 491 Future catchError(function(error), {bool test(var error)}) {
492 return _future.catchError(function, test: test); 492 return _future.catchError(function, test: test);
493 } 493 }
494 494
495 Future<T> whenComplete(action()) { 495 Future<T> whenComplete(action()) {
496 return _future.whenComplete(action); 496 return _future.whenComplete(action);
497 } 497 }
498 498
499 Stream<T> asStream() => new Stream.fromFuture(_future); 499 Stream<T> asStream() => new Stream.fromFuture(_future);
500 } 500 }
OLDNEW
« pkg/scheduled_test/lib/src/utils.dart ('K') | « pkg/unittest/test/unittest_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698