Class Dag
A dependency graph of systems — the third level of the runtime partitioning hierarchy (Engine → Track → DAG → Phase → System). A DAG belongs to
exactly one Track and declares its own ordered phase sequence.
public sealed class Dag
- Inheritance
-
Dag
- Inherited Members
Remarks
Every DAG is declared and executed the same way — there is no public/internal distinction. Systems are registered with CallbackSystem(string, Action<TickContext>, string, string[], SystemPriority, Func<bool>, int, int, int, bool) / QuerySystem(string, Action<TickContext>, string, string[], SystemPriority, Func<bool>, Func<ViewBase>, Type[], int, int, int, bool, bool, bool, SimTier, int, bool, float, int, RealmRate, RealmId[]) / PipelineSystem(string, Action<int, int>, int, string, string[], SystemPriority, Func<bool>, Func<ViewBase>, Type[], int, int, int, bool) (lambda style) or Add(CallbackSystem) (class-based, full RFC 07 access declarations).
Phases are DAG-local: a DAG that declares no phases via Phases(params Phase[]) gets a single implicit phase, and .After() edges order its
systems. There is no engine-global phase namespace.
Properties
Id
Flat global DAG id. Assigned by Build(IResource, ILogger); -1 before the schedule is built.
public int Id { get; }
Property Value
Name
DAG name — unique across the whole schedule.
public string Name { get; }
Property Value
ResolvedDefaultPhase
The phase assigned to systems registered without an explicit b.Phase(...) call.
public Phase ResolvedDefaultPhase { get; }
Property Value
ResolvedPhases
The DAG's ordered phase sequence. When Phases(params Phase[]) was never called this is a single implicit phase (Typhon.Engine.Dag.ImplicitPhaseName).
Phases form a DAG-local total order, and it binds through declared access only: a system in phase N+1 starts after a system in phase
N when their declarations conflict (rule ED-05), and may run alongside it otherwise.
public Phase[] ResolvedPhases { get; }
Property Value
- Phase[]
SystemIndices
Canonical indices (into Systems) of the systems belonging to this DAG. Populated by Build(IResource, ILogger); empty before the schedule is built.
public int[] SystemIndices { get; }
Property Value
- int[]
Track
The track this DAG belongs to.
public Track Track { get; }
Property Value
Methods
Add(CallbackSystem)
Register a class-based CallbackSystem.
public Dag Add(CallbackSystem system)
Parameters
systemCallbackSystem
Returns
Add(CompoundSystem)
Register a CompoundSystem. Expands all sub-systems into this DAG.
public Dag Add(CompoundSystem compound)
Parameters
compoundCompoundSystem
Returns
Add(PipelineSystem)
Register a class-based PipelineSystem. Not yet supported — execution model pending Patate design.
public Dag Add(PipelineSystem system)
Parameters
systemPipelineSystem
Returns
Add(QuerySystem)
Register a class-based QuerySystem.
public Dag Add(QuerySystem system)
Parameters
systemQuerySystem
Returns
Build(IResource, ILogger)
Builds the owning schedule into a DagScheduler. Forwards to Build(IResource, ILogger).
public DagScheduler Build(IResource parent, ILogger logger = null)
Parameters
Returns
CallbackSystem(string, Action<TickContext>, string, string[], SystemPriority, Func<bool>, int, int, int, bool)
Registers a CallbackSystem — lightweight single-invocation, no entity input.
public Dag CallbackSystem(string name, Action<TickContext> action, string after = null, string[] afterAll = null, SystemPriority priority = SystemPriority.Normal, Func<bool> shouldRun = null, int tickDivisor = 1, int throttledTickDivisor = 1, int tickOffset = -1, bool canShed = false)
Parameters
namestringactionAction<TickContext>afterstringafterAllstring[]prioritySystemPriorityshouldRunFunc<bool>tickDivisorintthrottledTickDivisorinttickOffsetintcanShedbool
Returns
ChunkedSystem<TChunk>(string, ChunkPrepare<TChunk>, ChunkExecute<TChunk>, string, string[], SystemPriority, Func<bool>, int, int, int, bool)
Registers a chunked system whose chunks each receive a typed record: prepare sizes and fills a ChunkTable<T> and
returns the chunk count (0 skips, -1 keeps one chunk), then execute runs once per chunk with that chunk's record. The lambda
form of ChunkedCallbackSystem<TContext, TChunk>: no ambient context, a lambda captures what it needs.
public Dag ChunkedSystem<TChunk>(string name, ChunkPrepare<TChunk> prepare, ChunkExecute<TChunk> execute, string after = null, string[] afterAll = null, SystemPriority priority = SystemPriority.Normal, Func<bool> shouldRun = null, int tickDivisor = 1, int throttledTickDivisor = 1, int tickOffset = -1, bool canShed = false) where TChunk : unmanaged
Parameters
namestringprepareChunkPrepare<TChunk>executeChunkExecute<TChunk>afterstringafterAllstring[]prioritySystemPriorityshouldRunFunc<bool>tickDivisorintthrottledTickDivisorinttickOffsetintcanShedbool
Returns
Type Parameters
TChunk
Consumes(string, params EventQueueBase[])
Declares that a system consumes the given event queues. Forwards to Consumes(string, params EventQueueBase[]).
public Dag Consumes(string systemName, params EventQueueBase[] queues)
Parameters
systemNamestringqueuesEventQueueBase[]
Returns
CreateEventQueue<T>(string, int)
Creates a typed event queue on the owning schedule. Forwards to CreateEventQueue<T>(string, int).
public EventQueue<T> CreateEventQueue<T>(string name, int capacity = 1024)
Parameters
Returns
- EventQueue<T>
Type Parameters
T
DefaultPhase(Phase)
Sets the phase assigned to systems that don't call b.Phase(...). Defaults to the first declared phase.
public Dag DefaultPhase(Phase phase)
Parameters
phasePhase
Returns
Phases(params Phase[])
Declares this DAG's ordered phase sequence. Phases form a DAG-local total order. May be called once;
omit it entirely for a trivial DAG that orders its systems with .After() edges only.
public Dag Phases(params Phase[] phases)
Parameters
phasesPhase[]
Returns
PipelineSystem(string, Action<int, int>, int, string, string[], SystemPriority, Func<bool>, Func<ViewBase>, Type[], int, int, int, bool)
Registers a PipelineSystem — multi-worker chunk-parallel execution.
public Dag PipelineSystem(string name, Action<int, int> chunkAction, int totalChunks, string after = null, string[] afterAll = null, SystemPriority priority = SystemPriority.Normal, Func<bool> shouldRun = null, Func<ViewBase> input = null, Type[] changeFilter = null, int tickDivisor = 1, int throttledTickDivisor = 1, int tickOffset = -1, bool canShed = false)
Parameters
namestringchunkActionAction<int, int>totalChunksintafterstringafterAllstring[]prioritySystemPriorityshouldRunFunc<bool>inputFunc<ViewBase>changeFilterType[]tickDivisorintthrottledTickDivisorinttickOffsetintcanShedbool
Returns
Produces(string, params EventQueueBase[])
Declares that a system produces the given event queues. Forwards to Produces(string, params EventQueueBase[]).
public Dag Produces(string systemName, params EventQueueBase[] queues)
Parameters
systemNamestringqueuesEventQueueBase[]
Returns
QuerySystem(string, Action<TickContext>, string, string[], SystemPriority, Func<bool>, Func<ViewBase>, Type[], int, int, int, bool, bool, bool, SimTier, int, bool, float, int, RealmRate, RealmId[])
Registers a QuerySystem — single-worker entity iteration.
public Dag QuerySystem(string name, Action<TickContext> action, string after = null, string[] afterAll = null, SystemPriority priority = SystemPriority.Normal, Func<bool> shouldRun = null, Func<ViewBase> input = null, Type[] changeFilter = null, int tickDivisor = 1, int throttledTickDivisor = 1, int tickOffset = -1, bool canShed = false, bool parallel = false, bool writesVersioned = false, SimTier tier = SimTier.All, int cellAmortize = 0, bool checkerboard = false, float chunksPerWorker = 1, int minChunkSize = 0, RealmRate realmRate = RealmRate.Divided, RealmId[] realms = null)
Parameters
namestringactionAction<TickContext>afterstringafterAllstring[]prioritySystemPriorityshouldRunFunc<bool>inputFunc<ViewBase>changeFilterType[]tickDivisorintthrottledTickDivisorinttickOffsetintcanShedboolparallelboolwritesVersionedbooltierSimTiercellAmortizeintcheckerboardboolchunksPerWorkerfloatminChunkSizeintrealmRateRealmRaterealmsRealmId[]