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

Side by Side Diff: lib/src/future_group.dart

Issue 1777453002: Modernize the package's style. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: Code review changes Created 4 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 | « lib/src/delegate/stream_subscription.dart ('k') | lib/src/lazy_stream.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 async.future_group;
6
7 import 'dart:async'; 5 import 'dart:async';
8 6
9 /// A collection of futures waits until all added [Future]s complete. 7 /// A collection of futures waits until all added [Future]s complete.
10 /// 8 ///
11 /// Futures are added to the group with [add]. Once you're finished adding 9 /// Futures are added to the group with [add]. Once you're finished adding
12 /// futures, signal that by calling [close]. Then, once all added futures have 10 /// futures, signal that by calling [close]. Then, once all added futures have
13 /// completed, [future] will complete with a list of values from the futures in 11 /// completed, [future] will complete with a list of values from the futures in
14 /// the group, in the order they were added. 12 /// the group, in the order they were added.
15 /// 13 ///
16 /// If any added future completes with an error, [future] will emit that error 14 /// If any added future completes with an error, [future] will emit that error
(...skipping 11 matching lines...) Expand all
28 var _closed = false; 26 var _closed = false;
29 27
30 /// The future that fires once [close] has been called and all futures in the 28 /// The future that fires once [close] has been called and all futures in the
31 /// group have completed. 29 /// group have completed.
32 /// 30 ///
33 /// This will also complete with an error if any of the futures in the group 31 /// This will also complete with an error if any of the futures in the group
34 /// fails, regardless of whether [close] was called. 32 /// fails, regardless of whether [close] was called.
35 Future<List<T>> get future => _completer.future; 33 Future<List<T>> get future => _completer.future;
36 final _completer = new Completer<List<T>>(); 34 final _completer = new Completer<List<T>>();
37 35
38 /// Whether this group is waiting on any futures. 36 /// Whether this group has no pending futures.
39 bool get isIdle => _pending == 0; 37 bool get isIdle => _pending == 0;
40 38
41 /// A broadcast stream that emits a `null` event whenever the last pending 39 /// A broadcast stream that emits a `null` event whenever the last pending
42 /// future in this group completes. 40 /// future in this group completes.
43 /// 41 ///
44 /// Once this group isn't waiting on any futures *and* [close] has been 42 /// Once this group isn't waiting on any futures *and* [close] has been
45 /// called, this stream will close. 43 /// called, this stream will close.
46 Stream get onIdle { 44 Stream get onIdle {
47 if (_onIdleController == null) { 45 if (_onIdleController == null) {
48 _onIdleController = new StreamController.broadcast(sync: true); 46 _onIdleController = new StreamController.broadcast(sync: true);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 /// Signals to the group that the caller is done adding futures, and so 87 /// Signals to the group that the caller is done adding futures, and so
90 /// [future] should fire once all added futures have completed. 88 /// [future] should fire once all added futures have completed.
91 void close() { 89 void close() {
92 _closed = true; 90 _closed = true;
93 if (_pending != 0) return; 91 if (_pending != 0) return;
94 if (_completer.isCompleted) return; 92 if (_completer.isCompleted) return;
95 _completer.complete(_values); 93 _completer.complete(_values);
96 } 94 }
97 } 95 }
98 96
OLDNEW
« no previous file with comments | « lib/src/delegate/stream_subscription.dart ('k') | lib/src/lazy_stream.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698