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

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

Issue 180473003: Barback transforms now pass through the primary input by default. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code reivew Created 6 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/barback/lib/src/asset_node_set.dart ('k') | pkg/barback/lib/src/phase_forwarder.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 barback.group_runner; 5 library barback.group_runner;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'asset_cascade.dart'; 9 import 'asset_cascade.dart';
10 import 'asset_node.dart'; 10 import 'asset_node.dart';
11 import 'asset_node_set.dart';
11 import 'log.dart'; 12 import 'log.dart';
12 import 'phase.dart'; 13 import 'phase.dart';
13 import 'stream_pool.dart'; 14 import 'stream_pool.dart';
14 import 'transformer_group.dart'; 15 import 'transformer_group.dart';
15 16
16 /// A class that processes all of the phases in a single transformer group. 17 /// A class that processes all of the phases in a single transformer group.
17 /// 18 ///
18 /// A group takes many inputs, processes them, and emits many outputs. 19 /// A group takes many inputs, processes them, and emits many outputs.
19 class GroupRunner { 20 class GroupRunner {
20 /// The group this runner runs. 21 /// The group this runner runs.
(...skipping 22 matching lines...) Expand all
43 Stream<LogEntry> get onLog => _onLogPool.stream; 44 Stream<LogEntry> get onLog => _onLogPool.stream;
44 final _onLogPool = new StreamPool<LogEntry>.broadcast(); 45 final _onLogPool = new StreamPool<LogEntry>.broadcast();
45 46
46 // TODO(nweiz): move to a more push-based way of propagating outputs and get 47 // TODO(nweiz): move to a more push-based way of propagating outputs and get
47 // rid of this. Once that's done, see if we can unify GroupRunner and 48 // rid of this. Once that's done, see if we can unify GroupRunner and
48 // AssetCascade. 49 // AssetCascade.
49 /// The set of outputs that has been returned by [process]. 50 /// The set of outputs that has been returned by [process].
50 /// 51 ///
51 /// [process] is expected to only return new outputs, so this is used to 52 /// [process] is expected to only return new outputs, so this is used to
52 /// ensure that it does so. 53 /// ensure that it does so.
53 final _alreadyEmittedOutputs = new Set<AssetNode>(); 54 final _alreadyEmittedOutputs = new AssetNodeSet();
54 55
55 GroupRunner(AssetCascade cascade, this._group, this._location) { 56 GroupRunner(AssetCascade cascade, this._group, this._location) {
56 var lastPhase = new Phase(cascade, _group.phases.first, _location); 57 var lastPhase = new Phase(cascade, _group.phases.first, _location);
57 _phases.add(lastPhase); 58 _phases.add(lastPhase);
58 for (var phase in _group.phases.skip(1)) { 59 for (var phase in _group.phases.skip(1)) {
59 lastPhase = lastPhase.addPhase(phase); 60 lastPhase = lastPhase.addPhase(phase);
60 _phases.add(lastPhase); 61 _phases.add(lastPhase);
61 } 62 }
62 63
63 for (var phase in _phases) { 64 for (var phase in _phases) {
(...skipping 27 matching lines...) Expand all
91 Future<Set<AssetNode>> process() { 92 Future<Set<AssetNode>> process() {
92 // Process the first phase that needs to do work. 93 // Process the first phase that needs to do work.
93 for (var phase in _phases) { 94 for (var phase in _phases) {
94 var future = phase.process(); 95 var future = phase.process();
95 if (future != null) return future.then((_) => process()); 96 if (future != null) return future.then((_) => process());
96 } 97 }
97 98
98 // If we get here, all phases are done processing. 99 // If we get here, all phases are done processing.
99 var newOutputs = _phases.last.availableOutputs 100 var newOutputs = _phases.last.availableOutputs
100 .difference(_alreadyEmittedOutputs); 101 .difference(_alreadyEmittedOutputs);
101 for (var output in newOutputs) {
102 output.whenRemoved(() => _alreadyEmittedOutputs.remove(output));
103 }
104 _alreadyEmittedOutputs.addAll(newOutputs); 102 _alreadyEmittedOutputs.addAll(newOutputs);
105 103
106 return new Future.value(newOutputs); 104 return new Future.value(newOutputs);
107 } 105 }
108 106
109 String toString() => "group in phase $_location for $_group"; 107 String toString() => "group in phase $_location for $_group";
110 } 108 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/asset_node_set.dart ('k') | pkg/barback/lib/src/phase_forwarder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698