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

Unified Diff: pkg/barback/lib/src/node_status.dart

Issue 255483002: Expand barback's notion of dirtiness to understand declaredness. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/barback/lib/src/group_runner.dart ('k') | pkg/barback/lib/src/node_streams.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/node_status.dart
diff --git a/pkg/barback/lib/src/node_status.dart b/pkg/barback/lib/src/node_status.dart
new file mode 100644
index 0000000000000000000000000000000000000000..21d26c6d08343cb46692214dad62811bde0abb70
--- /dev/null
+++ b/pkg/barback/lib/src/node_status.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library barback.node_status;
+
+/// The status of a node in barback's package graph.
+///
+/// A node has three possible statuses: [IDLE], [MATERIALIZING], and [RUNNING].
+/// These are ordered from least dirty to most dirty; the [dirtier] and
+/// [dirtiest] functions make use of this ordering.
+class NodeStatus {
+ /// The node has finished its work and won't do anything else until external
+ /// input causes it to.
+ ///
+ /// For deferred nodes, this may indicate that they're finished declaring
+ /// their outputs and waiting to be forced.
+ static const IDLE = const NodeStatus("idle");
+
+ /// The node has declared its outputs but their concrete values are still
+ /// being generated.
+ ///
+ /// This is only meaningful for nodes that are or contain declaring
+ /// transformers. Note that a lazy transformer that's declared its outputs but
+ /// isn't actively working to generate them is considered [IDLE], not
+ /// [MATERIALIZING].
+ static const MATERIALIZING = const NodeStatus("materializing");
+
+ /// The node is actively working on declaring or generating its outputs.
+ ///
+ /// Declaring transformers are only considered dirty until they're finished
+ /// declaring their outputs; past that point, they're always either
+ /// [MATERIALIZING] or [IDLE]. Non-declaring transformers, by contrast, are
+ /// always either [RUNNING] or [IDLE].
+ static const RUNNING = const NodeStatus("running");
+
+ final String _name;
+
+ /// Returns the dirtiest status in [statuses].
+ static NodeStatus dirtiest(Iterable<NodeStatus> statuses) =>
+ statuses.fold(NodeStatus.IDLE,
+ (status1, status2) => status1.dirtier(status2));
+
+ const NodeStatus(this._name);
+
+ String toString() => _name;
+
+ /// Returns [this] or [other], whichever is dirtier.
+ NodeStatus dirtier(NodeStatus other) {
+ if (this == RUNNING || other == RUNNING) return RUNNING;
+ if (this == MATERIALIZING || other == MATERIALIZING) return MATERIALIZING;
+ return IDLE;
+ }
+}
« no previous file with comments | « pkg/barback/lib/src/group_runner.dart ('k') | pkg/barback/lib/src/node_streams.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698