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

Side by Side Diff: pkg/analyzer/lib/src/cancelable_future.dart

Issue 975453004: Reformat (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | « pkg/analyzer/lib/src/analyzer_impl.dart ('k') | pkg/analyzer/lib/src/error_formatter.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library cancelable_future; 5 library cancelable_future;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 /** 9 /**
10 * Type of callback called when the future returned by a CancelableCompleter 10 * Type of callback called when the future returned by a CancelableCompleter
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 * never succeed--futures that have already completed retain their final 221 * never succeed--futures that have already completed retain their final
222 * state forever. 222 * state forever.
223 */ 223 */
224 void cancel(); 224 void cancel();
225 } 225 }
226 226
227 /** 227 /**
228 * Error which is used to complete any [CancelableFuture] which has been 228 * Error which is used to complete any [CancelableFuture] which has been
229 * successfully canceled by calling its 'cancel' method. 229 * successfully canceled by calling its 'cancel' method.
230 */ 230 */
231 class FutureCanceledError { 231 class FutureCanceledError {}
232 }
233 232
234 class _CancelableCompleterFuture<T> implements CancelableFuture<T> { 233 class _CancelableCompleterFuture<T> implements CancelableFuture<T> {
235 final CancelableCompleter<T> _completer; 234 final CancelableCompleter<T> _completer;
236 235
237 _CancelableCompleterFuture(this._completer); 236 _CancelableCompleterFuture(this._completer);
238 237
239 @override 238 @override
240 Stream<T> asStream() { 239 Stream<T> asStream() {
241 // TODO(paulberry): Implement this in such a way that 240 // TODO(paulberry): Implement this in such a way that
242 // StreamSubscription.cancel() cancels the future. 241 // StreamSubscription.cancel() cancels the future.
(...skipping 10 matching lines...) Expand all
253 _completer._outerCompleter.future.catchError(onError, test: test); 252 _completer._outerCompleter.future.catchError(onError, test: test);
254 253
255 @override 254 @override
256 Future then(onValue(T value), {Function onError}) => 255 Future then(onValue(T value), {Function onError}) =>
257 _completer._outerCompleter.future.then(onValue, onError: onError); 256 _completer._outerCompleter.future.then(onValue, onError: onError);
258 257
259 @override 258 @override
260 Future timeout(Duration timeLimit, {onTimeout()}) { 259 Future timeout(Duration timeLimit, {onTimeout()}) {
261 // TODO(paulberry): Implement this in such a way that a timeout cancels 260 // TODO(paulberry): Implement this in such a way that a timeout cancels
262 // the future. 261 // the future.
263 return _completer._outerCompleter.future.timeout( 262 return _completer._outerCompleter.future.timeout(timeLimit,
264 timeLimit,
265 onTimeout: onTimeout); 263 onTimeout: onTimeout);
266 } 264 }
267 265
268 @override 266 @override
269 Future<T> whenComplete(action()) => 267 Future<T> whenComplete(action()) =>
270 _completer._outerCompleter.future.whenComplete(action); 268 _completer._outerCompleter.future.whenComplete(action);
271 } 269 }
272 270
273 /** 271 /**
274 * A CancelableFuture that wraps an ordinary Future. Attempting to cancel a 272 * A CancelableFuture that wraps an ordinary Future. Attempting to cancel a
(...skipping 18 matching lines...) Expand all
293 Future then(onValue(value), {Function onError}) => 291 Future then(onValue(value), {Function onError}) =>
294 _future.then(onValue, onError: onError); 292 _future.then(onValue, onError: onError);
295 293
296 @override 294 @override
297 Future timeout(Duration timeLimit, {onTimeout()}) => 295 Future timeout(Duration timeLimit, {onTimeout()}) =>
298 _future.timeout(timeLimit, onTimeout: onTimeout); 296 _future.timeout(timeLimit, onTimeout: onTimeout);
299 297
300 @override 298 @override
301 Future whenComplete(action()) => _future.whenComplete(action); 299 Future whenComplete(action()) => _future.whenComplete(action);
302 } 300 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/analyzer_impl.dart ('k') | pkg/analyzer/lib/src/error_formatter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698