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

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

Issue 1299443002: Make generic type of timeout-future the same as the one from the original. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comment. Created 4 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
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 /** The onValue and onError handlers return either a value or a future */ 7 /** The onValue and onError handlers return either a value or a future */
8 typedef dynamic _FutureOnValue<T>(T value); 8 typedef dynamic _FutureOnValue<T>(T value);
9 /** Test used by [Future.catchError] to handle skip some errors. */ 9 /** Test used by [Future.catchError] to handle skip some errors. */
10 typedef bool _FutureErrorTest(var error); 10 typedef bool _FutureErrorTest(var error);
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 result._setValue(listenerValueOrError); 618 result._setValue(listenerValueOrError);
619 } else { 619 } else {
620 AsyncError asyncError = listenerValueOrError; 620 AsyncError asyncError = listenerValueOrError;
621 result._setErrorObject(asyncError); 621 result._setErrorObject(asyncError);
622 } 622 }
623 // Prepare for next round. 623 // Prepare for next round.
624 source = result; 624 source = result;
625 } 625 }
626 } 626 }
627 627
628 Future timeout(Duration timeLimit, {onTimeout()}) { 628 Future<T> timeout(Duration timeLimit, {onTimeout()}) {
629 if (_isComplete) return new _Future.immediate(this); 629 if (_isComplete) return new _Future.immediate(this);
630 _Future result = new _Future(); 630 _Future result = new _Future<T>();
631 Timer timer; 631 Timer timer;
632 if (onTimeout == null) { 632 if (onTimeout == null) {
633 timer = new Timer(timeLimit, () { 633 timer = new Timer(timeLimit, () {
634 result._completeError(new TimeoutException("Future not completed", 634 result._completeError(new TimeoutException("Future not completed",
635 timeLimit)); 635 timeLimit));
636 }); 636 });
637 } else { 637 } else {
638 Zone zone = Zone.current; 638 Zone zone = Zone.current;
639 onTimeout = zone.registerCallback(onTimeout); 639 onTimeout = zone.registerCallback(onTimeout);
640 timer = new Timer(timeLimit, () { 640 timer = new Timer(timeLimit, () {
(...skipping 11 matching lines...) Expand all
652 } 652 }
653 }, onError: (e, s) { 653 }, onError: (e, s) {
654 if (timer.isActive) { 654 if (timer.isActive) {
655 timer.cancel(); 655 timer.cancel();
656 result._completeError(e, s); 656 result._completeError(e, s);
657 } 657 }
658 }); 658 });
659 return result; 659 return result;
660 } 660 }
661 } 661 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698