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

Side by Side Diff: corelib/src/implementation/future_implementation.dart

Issue 9627002: future: fix future.immediate allocator (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 Google Inc. All Rights Reserved. 1 // Copyright 2011 Google Inc. All Rights Reserved.
2 // Dart core library. 2 // Dart core library.
3 3
4 class FutureImpl<T> implements Future<T> { 4 class FutureImpl<T> implements Future<T> {
5 5
6 bool _isComplete; 6 bool _isComplete;
7 7
8 /** 8 /**
9 * Value that was provided to this Future by the Completer 9 * Value that was provided to this Future by the Completer
10 */ 10 */
(...skipping 18 matching lines...) Expand all
29 /** 29 /**
30 * Exception handlers waiting for exceptions. 30 * Exception handlers waiting for exceptions.
31 */ 31 */
32 final List<Function> _exceptionHandlers; 32 final List<Function> _exceptionHandlers;
33 33
34 FutureImpl() : _listeners = new List(), _exceptionHandlers = new List() { 34 FutureImpl() : _listeners = new List(), _exceptionHandlers = new List() {
35 _isComplete = false; 35 _isComplete = false;
36 _exceptionHandled = false; 36 _exceptionHandled = false;
37 } 37 }
38 38
39 FutureImpl.immediate(T value) : this() { 39 factory FutureImpl.immediate(T value) {
40 _setValue(value); 40 final res = new FutureImpl();
41 res._setValue(value);
42 return res;
41 } 43 }
42 44
43 T get value() { 45 T get value() {
44 if (!isComplete) { 46 if (!isComplete) {
45 throw new FutureNotCompleteException(); 47 throw new FutureNotCompleteException();
46 } 48 }
47 if (_exception !== null) { 49 if (_exception !== null) {
48 throw _exception; 50 throw _exception;
49 } 51 }
50 return _value; 52 return _value;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 183 }
182 184
183 void complete(T value) { 185 void complete(T value) {
184 _futureImpl._setValue(value); 186 _futureImpl._setValue(value);
185 } 187 }
186 188
187 void completeException(var exception) { 189 void completeException(var exception) {
188 _futureImpl._setException(exception); 190 _futureImpl._setException(exception);
189 } 191 }
190 } 192 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698