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

Side by Side Diff: sdk/lib/async/future.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
« no previous file with comments | « no previous file | sdk/lib/async/future_impl.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 /** 7 /**
8 * An object representing a delayed computation. 8 * An object representing a delayed computation.
9 * 9 *
10 * A [Future] is used to represent a potential value, or error, 10 * A [Future] is used to represent a potential value, or error,
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 539
540 /** 540 /**
541 * Time-out the future computation after [timeLimit] has passed. 541 * Time-out the future computation after [timeLimit] has passed.
542 * 542 *
543 * Returns a new future that completes with the same value as this future, 543 * Returns a new future that completes with the same value as this future,
544 * if this future completes in time. 544 * if this future completes in time.
545 * 545 *
546 * If this future does not complete before `timeLimit` has passed, 546 * If this future does not complete before `timeLimit` has passed,
547 * the [onTimeout] action is executed instead, and its result (whether it 547 * the [onTimeout] action is executed instead, and its result (whether it
548 * returns or throws) is used as the result of the returned future. 548 * returns or throws) is used as the result of the returned future.
549 * The [onTimeout] function must return a [T] or a `Future<T>`.
549 * 550 *
550 * If `onTimeout` is omitted, a timeout will cause the returned future to 551 * If `onTimeout` is omitted, a timeout will cause the returned future to
551 * complete with a [TimeoutException]. 552 * complete with a [TimeoutException].
552 */ 553 */
553 Future timeout(Duration timeLimit, {onTimeout()}); 554 Future<T> timeout(Duration timeLimit, {onTimeout()});
554 } 555 }
555 556
556 /** 557 /**
557 * Thrown when a scheduled timeout happens while waiting for an async result. 558 * Thrown when a scheduled timeout happens while waiting for an async result.
558 */ 559 */
559 class TimeoutException implements Exception { 560 class TimeoutException implements Exception {
560 /** Description of the cause of the timeout. */ 561 /** Description of the cause of the timeout. */
561 final String message; 562 final String message;
562 /** The duration that was exceeded. */ 563 /** The duration that was exceeded. */
563 final Duration duration; 564 final Duration duration;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 if (replacement != null) { 746 if (replacement != null) {
746 error = _nonNullError(replacement.error); 747 error = _nonNullError(replacement.error);
747 stackTrace = replacement.stackTrace; 748 stackTrace = replacement.stackTrace;
748 } 749 }
749 result._completeError(error, stackTrace); 750 result._completeError(error, stackTrace);
750 } 751 }
751 752
752 /** Helper function that converts `null` to a [NullThrownError]. */ 753 /** Helper function that converts `null` to a [NullThrownError]. */
753 Object _nonNullError(Object error) => 754 Object _nonNullError(Object error) =>
754 (error != null) ? error : new NullThrownError(); 755 (error != null) ? error : new NullThrownError();
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/async/future_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698