]> git.ozlabs.org Git - ccan/commitdiff
aga: Add aga_node_needs_update() internal function
authorDavid Gibson <david@gibson.dropbear.id.au>
Thu, 12 Nov 2015 11:21:10 +0000 (22:21 +1100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Thu, 12 Nov 2015 11:22:18 +0000 (22:22 +1100)
There are situations where aga algorithms may want to check if a node is
up-to-date (i.e. has yet been discovered by the current algorithm) without
making it up to date if it's not.  This adds an internal function to do so.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
ccan/aga/aga.c
ccan/aga/private.h

index c1880ec54278f13c66b28ded097a25a997611d34..c721b1440e6de41b8e69fa8ad2ae67d8ca408fa9 100644 (file)
@@ -58,9 +58,15 @@ void aga_finish(struct aga_graph *g)
        g->sequence++;
 }
 
+bool aga_node_needs_update(const struct aga_graph *g,
+                          const struct aga_node *node)
+{
+       return (node->sequence != g->sequence);
+}
+
 bool aga_update_node(const struct aga_graph *g, struct aga_node *node)
 {
-       if (node->sequence == g->sequence)
+       if (!aga_node_needs_update(g, node))
                return false;
 
        node->sequence = g->sequence;
index ff9f189441a27a2ed03f22feda17c1fb03539ce8..3095d3bca032fd27ceb903105b154c1d9d57f5b2 100644 (file)
@@ -3,6 +3,8 @@
 #define CCAN_AGA_PRIVATE_H
 
 int aga_start(struct aga_graph *g);
+bool aga_node_needs_update(const struct aga_graph *g,
+                          const struct aga_node *node);
 bool aga_update_node(const struct aga_graph *g, struct aga_node *node);
 bool aga_check_state(const struct aga_graph *g);
 void aga_fail(struct aga_graph *g, int error);