Commit c067e5e0 authored by David Gibson's avatar David Gibson

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: default avatarDavid Gibson <david@gibson.dropbear.id.au>
parent e95575c4
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment