| OLD | NEW |
| 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 'barback_logger.dart'; | 11 import 'log.dart'; |
| 12 import 'phase.dart'; | 12 import 'phase.dart'; |
| 13 import 'stream_pool.dart'; | 13 import 'stream_pool.dart'; |
| 14 import 'transformer_group.dart'; | 14 import 'transformer_group.dart'; |
| 15 | 15 |
| 16 /// A class that process all of the phases in a single transformer group. | 16 /// A class that process all of the phases in a single transformer group. |
| 17 /// | 17 /// |
| 18 /// A group takes many inputs, processes them, and emits many outputs. | 18 /// A group takes many inputs, processes them, and emits many outputs. |
| 19 class GroupRunner { | 19 class GroupRunner { |
| 20 /// The phases defined by this group. | 20 /// The phases defined by this group. |
| 21 final _phases = new List<Phase>(); | 21 final _phases = new List<Phase>(); |
| 22 | 22 |
| 23 /// A stream that emits an event whenever this group becomes dirty and needs | 23 /// A stream that emits an event whenever this group becomes dirty and needs |
| 24 /// to be run. | 24 /// to be run. |
| 25 /// | 25 /// |
| 26 /// This may emit events when the group was already dirty or while processing | 26 /// This may emit events when the group was already dirty or while processing |
| 27 /// transforms. Events are emitted synchronously to ensure that the dirty | 27 /// transforms. Events are emitted synchronously to ensure that the dirty |
| 28 /// state is thoroughly propagated as soon as any assets are changed. | 28 /// state is thoroughly propagated as soon as any assets are changed. |
| 29 Stream get onDirty => _onDirtyPool.stream; | 29 Stream get onDirty => _onDirtyPool.stream; |
| 30 final _onDirtyPool = new StreamPool.broadcast(); | 30 final _onDirtyPool = new StreamPool.broadcast(); |
| 31 | 31 |
| 32 /// Whether this group is dirty and needs to be run. | 32 /// Whether this group is dirty and needs to be run. |
| 33 bool get isDirty => _phases.any((phase) => phase.isDirty); | 33 bool get isDirty => _phases.any((phase) => phase.isDirty); |
| 34 | 34 |
| 35 /// A stream that emits an event whenever any transforms in this group log an | 35 /// A stream that emits an event whenever any transforms in this group logs |
| 36 /// entry. | 36 /// an entry. |
| 37 Stream<LogEntry> get onLog => _onLogPool.stream; | 37 Stream<LogEntry> get onLog => _onLogPool.stream; |
| 38 final _onLogPool = new StreamPool<LogEntry>.broadcast(); | 38 final _onLogPool = new StreamPool<LogEntry>.broadcast(); |
| 39 | 39 |
| 40 // TODO(nweiz): move to a more push-based way of propagating outputs and get | 40 // TODO(nweiz): move to a more push-based way of propagating outputs and get |
| 41 // rid of this. Once that's done, see if we can unify GroupRunner and | 41 // rid of this. Once that's done, see if we can unify GroupRunner and |
| 42 // AssetCascade. | 42 // AssetCascade. |
| 43 /// The set of outputs that has been returned by [process]. | 43 /// The set of outputs that has been returned by [process]. |
| 44 /// | 44 /// |
| 45 /// [process] is expected to only return new outputs, so this is used to | 45 /// [process] is expected to only return new outputs, so this is used to |
| 46 /// ensure that it does so. | 46 /// ensure that it does so. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 var newOutputs = _phases.last.availableOutputs | 85 var newOutputs = _phases.last.availableOutputs |
| 86 .difference(_alreadyEmittedOutputs); | 86 .difference(_alreadyEmittedOutputs); |
| 87 for (var output in newOutputs) { | 87 for (var output in newOutputs) { |
| 88 output.whenRemoved(() => _alreadyEmittedOutputs.remove(output)); | 88 output.whenRemoved(() => _alreadyEmittedOutputs.remove(output)); |
| 89 } | 89 } |
| 90 _alreadyEmittedOutputs.addAll(newOutputs); | 90 _alreadyEmittedOutputs.addAll(newOutputs); |
| 91 | 91 |
| 92 return new Future.value(newOutputs); | 92 return new Future.value(newOutputs); |
| 93 } | 93 } |
| 94 } | 94 } |
| OLD | NEW |