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

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

Issue 11794043: Remove Signal class and use Future/.whenComplete instead. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comment updated. Created 7 years, 11 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
« no previous file with comments | « sdk/lib/async/future.dart ('k') | sdk/lib/async/signal.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 deprecatedFutureValue(_FutureImpl future) => 7 deprecatedFutureValue(_FutureImpl future) =>
8 future._isComplete ? future._resultOrListeners : null; 8 future._isComplete ? future._resultOrListeners : null;
9 9
10 10
11 class _CompleterImpl<T> implements Completer<T> { 11 class _CompleterImpl<T> implements Completer<T> {
12 final Future<T> future; 12 final Future<T> future;
13 bool _isComplete = false; 13 bool _isComplete = false;
14 14
15 _CompleterImpl() : future = new _FutureImpl<T>(); 15 _CompleterImpl() : future = new _FutureImpl<T>();
16 16
17 void complete(T value) { 17 void complete([T value]) {
18 if (_isComplete) throw new StateError("Future already completed"); 18 if (_isComplete) throw new StateError("Future already completed");
19 _isComplete = true; 19 _isComplete = true;
20 _FutureImpl future = this.future; 20 _FutureImpl future = this.future;
21 future._setValue(value); 21 future._setValue(value);
22 } 22 }
23 23
24 void completeError(Object error, [Object stackTrace = null]) { 24 void completeError(Object error, [Object stackTrace = null]) {
25 if (_isComplete) throw new StateError("Future already completed"); 25 if (_isComplete) throw new StateError("Future already completed");
26 _isComplete = true; 26 _isComplete = true;
27 new Timer(0, (_) { 27 new Timer(0, (_) {
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 Future catchError(function(AsyncError error), {bool test(var error)}) { 451 Future catchError(function(AsyncError error), {bool test(var error)}) {
452 return _future.catchError(function, test: test); 452 return _future.catchError(function, test: test);
453 } 453 }
454 454
455 Future whenComplete(void action()) { 455 Future whenComplete(void action()) {
456 return _future.whenComplete(action); 456 return _future.whenComplete(action);
457 } 457 }
458 458
459 Stream<T> asStream() => new Stream.fromFuture(this); 459 Stream<T> asStream() => new Stream.fromFuture(this);
460 } 460 }
OLDNEW
« no previous file with comments | « sdk/lib/async/future.dart ('k') | sdk/lib/async/signal.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698