Vixen
02b45cc4
csharp
public sealed class SystemGraph

Systems, ordered per phase, with the data dependencies between them worked out.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Two passes. First the explicit ordering — UpdateBeforeAttribute and UpdateAfterAttribute — is resolved into a total order by a topological sort, with registration order breaking ties so that a graph with no constraints runs in the order it was written. Then, walking that order, each system takes a dependency on every earlier system it conflicts with.

The result is a schedule, not a sequence: systems with disjoint writes get the same dependency and run at the same time. A phase costs its critical path.

Only the last conflicting predecessor per chain would be enough, and computing the transitive reduction is not worth it — the job system takes a handful of handles for nothing, and a reduction that is wrong loses an edge, which is a data race.

Fields and properties (2)

  • public IEnumerable<SystemPhase> Phases

    The phases that have systems in them, in execution order.

  • public IEnumerable<SystemNode> All

    Every system, in phase order and then in execution order.

Methods (4)

  • public IReadOnlyList<SystemNode> InPhase(SystemPhase phase)

    The systems in a phase, in execution order.

  • public static SystemGraph Build(IReadOnlyList<ISystem> systems)

    Builds the graph from systems in registration order.

  • public string ToDot()

    Renders the graph as Graphviz DOT.

  • public string ToMermaid()

    Renders the graph as Mermaid, which pastes straight into a pull request.

Used by (3)

  • EngineLoopTestsVixen.Engine.Tests
  • SystemRunnerVixen.Ecs
  • SystemTestsVixen.Ecs.Tests