Class DagBuilder
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
namestringUnique name identifying this system.
actionAction<TickContext>Delegate invoked once per tick on a single worker.
prioritySystemPriorityScheduling priority (enforcement deferred to #201).
shouldRunFunc<bool>Optional predicate — when it returns
false, the system is skipped for that tick.
Returns
AddEdge(string, string)
Adds a dependency edge: from must complete before to can start.
public DagBuilder AddEdge(string from, string to)
Parameters
Returns
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
namestringUnique name identifying this system.
chunkActionAction<int, int>Delegate called per chunk with (chunkIndex, totalChunks). Must be thread-safe.
totalChunksintNumber of chunks to distribute across workers.
prioritySystemPriorityScheduling priority (enforcement deferred to #201).
shouldRunFunc<bool>Optional predicate — if false, system is skipped.
instanceISystemOptional class-based system instance backing this registration;
nullfor a delegate-only pipeline system.
Returns
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
namestringUnique name identifying this system.
actionAction<TickContext>Delegate invoked once per tick on a single worker.
prioritySystemPriorityScheduling priority (enforcement deferred to #201).
shouldRunFunc<bool>Optional predicate — if false, system is skipped.
Returns
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.