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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
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.
4
5 library barback.node_status;
6
7 /// The status of a node in barback's package graph.
8 ///
9 /// A node has three possible statuses: [DONE], [DECLARED], and [DIRTY]. These
10 /// are ordered from least dirty to most dirty; the [dirtier] and [dirtiest]
11 /// functions make use of this ordering.
12 class NodeStatus {
13 /// The node has finished its work and won't do anything else until external
14 /// input causes it to.
15 ///
16 /// For deferred nodes, this may indicate that they're finished declaring
17 /// their outputs and waiting to be forced.
18 static const DONE = const NodeStatus("done");
19
20 /// The node has declared its outputs but their concrete values are still
21 /// being generated.
22 ///
23 /// This is only meaningful for nodes that are or contain declaring
24 /// transformers. Note that a lazy transformer that's declared its outputs but
25 /// isn't actively working to generate them is considered [DONE], not
26 /// [DECLARED].
Bob Nystrom 2014/04/25 22:02:33 This is super confusing. Why isn't it DECLARED?
nweiz 2014/04/28 21:02:00 Because the node's concrete value isn't being gene
Bob Nystrom 2014/04/29 18:34:43 That makes sense, but the terminology is misleadin
nweiz 2014/04/29 20:11:26 Done.
27 static const DECLARED = const NodeStatus("declared");
28
29 /// The node is actively working on declaring or generating its outputs.
30 ///
31 /// Declaring transformers are only considered dirty until they're finished
32 /// declaring their outputs; past that point, they're always either [DECLARED]
33 /// or [DONE]. Non-declaring transformers, by contrast, are always either
34 /// [DIRTY] or [DONE].
35 static const DIRTY = const NodeStatus("dirty");
36
37 final String _name;
38
39 /// Returns the dirtiest status in [statuses].
40 static NodeStatus dirtiest(Iterable<NodeStatus> statuses) =>
41 statuses.fold(NodeStatus.DONE,
42 (status1, status2) => status1.dirtier(status2));
43
44 const NodeStatus(this._name);
45
46 String toString() => _name;
47
48 /// Returns [this] or [other], whichever is dirtier.
49 NodeStatus dirtier(NodeStatus other) {
50 if (this == DIRTY || other == DIRTY) return DIRTY;
51 if (this == DECLARED || other == DECLARED) return DECLARED;
52 return DONE;
53 }
54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698