Browse Source

aga: Add aga_node_needs_update() internal function

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>
David Gibson 10 years ago
parent
commit
c067e5e08b
2 changed files with 9 additions and 1 deletions
  1. 7 1
      ccan/aga/aga.c
  2. 2 0
      ccan/aga/private.h

+ 7 - 1
ccan/aga/aga.c

@@ -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;

+ 2 - 0
ccan/aga/private.h

@@ -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);