Table of Contents

Class DagBuilder

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Fluent builder for constructing a static system DAG. Validates uniqueness and acyclicity on Build().

public sealed class DagBuilder
Inheritance
DagBuilder
Inherited Members

Remarks

Systems are added with AddCallbackSystem(string, Action<TickContext>, SystemPriority, Func<bool>) or AddPipelineSystem(string, Action<int, int>, int, SystemPriority, Func<bool>, ISystem), then connected with AddEdge(string, string). Call Build() to produce an immutable SystemDefinition array with computed predecessors, successors, and topological order.

Constructors

DagBuilder()

public DagBuilder()

Methods

AddCallbackSystem(string, Action<TickContext>, SystemPriority, Func<bool>)

Adds a CallbackSystem (single-invocation, inline on dispatching worker).

public DagBuilder AddCallbackSystem(string name, Action<TickContext> action, SystemPriority priority = SystemPriority.Normal, Func<bool> shouldRun = null)

Parameters

name string

Unique name identifying this system.

action Action<TickContext>

Delegate invoked once per tick on a single worker.

priority SystemPriority

Scheduling priority (enforcement deferred to #201).

shouldRun Func<bool>

Optional predicate — when it returns false, the system is skipped for that tick.

Returns

DagBuilder

AddEdge(string, string)

Adds a dependency edge: from must complete before to can start.

public DagBuilder AddEdge(string from, string to)

Parameters

from string
to string

Returns

DagBuilder

AddPipelineSystem(string, Action<int, int>, int, SystemPriority, Func<bool>, ISystem)

Adds a PipelineSystem (multi-worker chunk-parallel execution).

public DagBuilder AddPipelineSystem(string name, Action<int, int> chunkAction, int totalChunks, SystemPriority priority = SystemPriority.Normal, Func<bool> shouldRun = null, ISystem instance = null)

Parameters

name string

Unique name identifying this system.

chunkAction Action<int, int>

Delegate called per chunk with (chunkIndex, totalChunks). Must be thread-safe.

totalChunks int

Number of chunks to distribute across workers.

priority SystemPriority

Scheduling priority (enforcement deferred to #201).

shouldRun Func<bool>

Optional predicate — if false, system is skipped.

instance ISystem

Optional class-based system instance backing this registration; null for a delegate-only pipeline system.

Returns

DagBuilder

AddQuerySystem(string, Action<TickContext>, SystemPriority, Func<bool>)

Adds a QuerySystem (single-worker entity iteration).

public DagBuilder AddQuerySystem(string name, Action<TickContext> action, SystemPriority priority = SystemPriority.Normal, Func<bool> shouldRun = null)

Parameters

name string

Unique name identifying this system.

action Action<TickContext>

Delegate invoked once per tick on a single worker.

priority SystemPriority

Scheduling priority (enforcement deferred to #201).

shouldRun Func<bool>

Optional predicate — if false, system is skipped.

Returns

DagBuilder

Build()

Builds the DAG: computes successors, predecessor counts, topological order, and validates acyclicity.

public (SystemDefinition[] Systems, int[] TopologicalOrder) Build()

Returns

(SystemDefinition[] Systems, int[] TopologicalOrder)

Immutable array of SystemDefinition with all graph metadata computed.

Exceptions

InvalidOperationException

The graph contains a cycle.