AdaCore / e3-core

Core framework for developing portable automated build systems
26 stars 36 forks source link

Iterate a DAG with cycles with the "enable_busy_state" loops #717

Closed Jicquel closed 5 months ago

Jicquel commented 5 months ago

A simple reproducer:

d = DAG()
d.add_vertex("a")
d.add_vertex("b")
d.update_vertex("a", predecessors=["b"])

it = DAGIterator(d, enable_busy_state=True)
[k for k, _ in it]

The iteration will never end, as the loop is not detected. Non-visited nodes are waiting for predecessors as if the latter were in the busy state.

Jicquel commented 5 months ago

I did not paste the correct reproducer: here it is:

d = DAG()
d.add_vertex("a")
d.add_vertex("b")
d.update_vertex("a", predecessors=["b"])
# Force the creation of a cycle
d.update_vertex("b", data="newb", predecessors=["a"], enable_checks=False)

it = DAGIterator(d, enable_busy_state=True)
[k for k, _ in it]

As the comment explains (coming from tests/tests_e3/collection/dag/main_test.py), checks are implicit during vertices insertion and modification. I will close this issue, as the checks are made before iterating over the DAG.