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

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

Issue 21097006: Add a library name for cancelable_future.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 import 'dart:async'; 1 import 'dart:async';
2 2
3 library barback.cancelable_future;
4
3 /// A wrapper for [Future] that can be cancelled. 5 /// A wrapper for [Future] that can be cancelled.
4 /// 6 ///
5 /// When this is cancelled, that means it won't complete either successfully or 7 /// When this is cancelled, that means it won't complete either successfully or
6 /// with an error, regardless of whether the wrapped Future completes. 8 /// with an error, regardless of whether the wrapped Future completes.
7 /// Cancelling this won't stop whatever code is feeding the wrapped future from 9 /// Cancelling this won't stop whatever code is feeding the wrapped future from
8 /// running. 10 /// running.
9 class CancelableFuture<T> implements Future<T> { 11 class CancelableFuture<T> implements Future<T> {
10 bool _canceled = false; 12 bool _canceled = false;
11 final _completer = new Completer<T>(); 13 final _completer = new Completer<T>();
12 14
(...skipping 12 matching lines...) Expand all
25 _completer.future.catchError(onError, test: test); 27 _completer.future.catchError(onError, test: test);
26 Future then(onValue(T value), {onError(error)}) => 28 Future then(onValue(T value), {onError(error)}) =>
27 _completer.future.then(onValue, onError: onError); 29 _completer.future.then(onValue, onError: onError);
28 Future<T> whenComplete(action()) => _completer.future.whenComplete(action); 30 Future<T> whenComplete(action()) => _completer.future.whenComplete(action);
29 31
30 /// Cancels this future. 32 /// Cancels this future.
31 void cancel() { 33 void cancel() {
32 _canceled = true; 34 _canceled = true;
33 } 35 }
34 } 36 }
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