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

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

Issue 2724853002: Revert last 4 commits by lrn@ (Closed)
Patch Set: Created 3 years, 9 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 | « runtime/vm/parser.cc ('k') | 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 /// A type representing values that are either `Future<T>` or `T`. 7 /// A type representing values that are either `Future<T>` or `T`.
8 /// 8 ///
9 /// This class declaration is a public stand-in for an internal 9 /// This class declaration is a public stand-in for an internal
10 /// future-or-value generic type. References to this class are resolved to the 10 /// future-or-value generic type. References to this class are resolved to the
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 * if (onError is ZoneBinaryCallback) { 546 * if (onError is ZoneBinaryCallback) {
547 * return onError(e, stackTrace); 547 * return onError(e, stackTrace);
548 * } 548 * }
549 * return onError(e); 549 * return onError(e);
550 * } 550 * }
551 * throw e; 551 * throw e;
552 * }); 552 * });
553 * } 553 * }
554 * 554 *
555 */ 555 */
556 // The `Function` below stands for one of two types: 556 // The `Function` below can stand for several types:
557 // - (dynamic) -> FutureOr<T> 557 // - (dynamic) -> T
558 // - (dynamic, StackTrace) -> FutureOr<T> 558 // - (dynamic, StackTrace) -> T
559 // - (dynamic) -> Future<T>
560 // - (dynamic, StackTrace) -> Future<T>
559 // Given that there is a `test` function that is usually used to do an 561 // Given that there is a `test` function that is usually used to do an
560 // `isCheck` we should also expect functions that take a specific argument. 562 // `isCheck` we should also expect functions that take a specific argument.
561 // Note: making `catchError` return a `Future<T>` in non-strong mode could be 563 // Note: making `catchError` return a `Future<T>` in non-strong mode could be
562 // a breaking change. 564 // a breaking change.
563 Future<T> catchError(Function onError, 565 Future<T> catchError(Function onError,
564 {bool test(Object error)}); 566 {bool test(Object error)});
565 567
566 /** 568 /**
567 * Register a function to be called when this future completes. 569 * Register a function to be called when this future completes.
568 * 570 *
569 * The [action] function is called when this future completes, whether it 571 * The [action] function is called when this future completes, whether it
570 * does so with a value or with an error. 572 * does so with a value or with an error.
571 * 573 *
572 * This is the asynchronous equivalent of a "finally" block. 574 * This is the asynchronous equivalent of a "finally" block.
573 * 575 *
574 * The future returned by this call, `f`, will complete the same way 576 * The future returned by this call, `f`, will complete the same way
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 * or a future of type `Future<T>`. 778 * or a future of type `Future<T>`.
777 * 779 *
778 * If the value is itself a future, the completer will wait for that future 780 * If the value is itself a future, the completer will wait for that future
779 * to complete, and complete with the same result, whether it is a success 781 * to complete, and complete with the same result, whether it is a success
780 * or an error. 782 * or an error.
781 * 783 *
782 * Calling `complete` or [completeError] must not be done more than once. 784 * Calling `complete` or [completeError] must not be done more than once.
783 * 785 *
784 * All listeners on the future are informed about the value. 786 * All listeners on the future are informed about the value.
785 */ 787 */
786 void complete([FutureOr<T> value]); 788 void complete([value]);
787 789
788 /** 790 /**
789 * Complete [future] with an error. 791 * Complete [future] with an error.
790 * 792 *
791 * Calling [complete] or `completeError` must not be done more than once. 793 * Calling [complete] or `completeError` must not be done more than once.
792 * 794 *
793 * Completing a future with an error indicates that an exception was thrown 795 * Completing a future with an error indicates that an exception was thrown
794 * while trying to produce a value. 796 * while trying to produce a value.
795 * 797 *
796 * If [error] is `null`, it is replaced by a [NullThrownError]. 798 * If [error] is `null`, it is replaced by a [NullThrownError].
(...skipping 21 matching lines...) Expand all
818 void _completeWithErrorCallback(_Future result, error, stackTrace) { 820 void _completeWithErrorCallback(_Future result, error, stackTrace) {
819 AsyncError replacement = Zone.current.errorCallback(error, stackTrace); 821 AsyncError replacement = Zone.current.errorCallback(error, stackTrace);
820 if (replacement != null) { 822 if (replacement != null) {
821 error = _nonNullError(replacement.error); 823 error = _nonNullError(replacement.error);
822 stackTrace = replacement.stackTrace; 824 stackTrace = replacement.stackTrace;
823 } 825 }
824 result._completeError(error, stackTrace); 826 result._completeError(error, stackTrace);
825 } 827 }
826 828
827 /** Helper function that converts `null` to a [NullThrownError]. */ 829 /** Helper function that converts `null` to a [NullThrownError]. */
828 Object _nonNullError(Object error) => error ?? new NullThrownError(); 830 Object _nonNullError(Object error) =>
831 (error != null) ? error : new NullThrownError();
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | sdk/lib/async/future_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698