Table of Contents

Class Dag

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

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, bool) / QuerySystem(string, Action<TickContext>, string, string[], SystemPriority, Func<bool>, Func<ViewBase>, Type[], int, int, bool, bool, bool, SimTier, int, bool, float) / PipelineSystem(string, Action<int, int>, int, string, string[], SystemPriority, Func<bool>, Func<ViewBase>, Type[], 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

int

Name

DAG name — unique across the whole schedule.

public string Name { get; }

Property Value

string

ResolvedDefaultPhase

The phase assigned to systems registered without an explicit b.Phase(...) call.

public Phase ResolvedDefaultPhase { get; }

Property Value

Phase

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 — every system in phase N completes before any system in phase N+1 of the same DAG.

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

Track

Methods

Add(CallbackSystem)

Register a class-based CallbackSystem.

public Dag Add(CallbackSystem system)

Parameters

system CallbackSystem

Returns

Dag

Add(CompoundSystem)

Register a CompoundSystem. Expands all sub-systems into this DAG.

public Dag Add(CompoundSystem compound)

Parameters

compound CompoundSystem

Returns

Dag

Add(PipelineSystem)

Register a class-based PipelineSystem. Not yet supported — execution model pending Patate design.

public Dag Add(PipelineSystem system)

Parameters

system PipelineSystem

Returns

Dag

Add(QuerySystem)

Register a class-based QuerySystem.

public Dag Add(QuerySystem system)

Parameters

system QuerySystem

Returns

Dag

Build(IResource, ILogger)

Builds the owning schedule into a DagScheduler. Forwards to Build(IResource, ILogger).

public DagScheduler Build(IResource parent, ILogger logger = null)

Parameters

parent IResource
logger ILogger

Returns

DagScheduler

CallbackSystem(string, Action<TickContext>, string, string[], SystemPriority, Func<bool>, 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, bool canShed = false)

Parameters

name string
action Action<TickContext>
after string
afterAll string[]
priority SystemPriority
shouldRun Func<bool>
tickDivisor int
throttledTickDivisor int
canShed bool

Returns

Dag

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

systemName string
queues EventQueueBase[]

Returns

Dag

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

name string
capacity int

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

phase Phase

Returns

Dag

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

phases Phase[]

Returns

Dag

PipelineSystem(string, Action<int, int>, int, string, string[], SystemPriority, Func<bool>, Func<ViewBase>, Type[], 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, bool canShed = false)

Parameters

name string
chunkAction Action<int, int>
totalChunks int
after string
afterAll string[]
priority SystemPriority
shouldRun Func<bool>
input Func<ViewBase>
changeFilter Type[]
tickDivisor int
throttledTickDivisor int
canShed bool

Returns

Dag

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

systemName string
queues EventQueueBase[]

Returns

Dag

QuerySystem(string, Action<TickContext>, string, string[], SystemPriority, Func<bool>, Func<ViewBase>, Type[], int, int, bool, bool, bool, SimTier, int, bool, float)

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, bool canShed = false, bool parallel = false, bool writesVersioned = false, SimTier tier = SimTier.All, int cellAmortize = 0, bool checkerboard = false, float chunksPerWorker = 1)

Parameters

name string
action Action<TickContext>
after string
afterAll string[]
priority SystemPriority
shouldRun Func<bool>
input Func<ViewBase>
changeFilter Type[]
tickDivisor int
throttledTickDivisor int
canShed bool
parallel bool
writesVersioned bool
tier SimTier
cellAmortize int
checkerboard bool
chunksPerWorker float

Returns

Dag