Class TyphonRuntime
Top-level runtime for Typhon game servers. Wraps DatabaseEngine and DagScheduler, managing the per-tick UoW/Transaction lifecycle so game developers never handle commits manually.
public sealed class TyphonRuntime : IDisposable
- Inheritance
-
TyphonRuntime
- Implements
- Inherited Members
Remarks
Each tick: creates a UoW (Deferred) → for each CallbackSystem/QuerySystem, creates a Transaction on the executing worker thread (respecting thread affinity) → commits after each system → flushes UoW at tick end.
Pipeline systems do not receive Transactions — their entity access goes through Gather/Scatter pipelines.
Properties
CurrentOverloadLevel
Current overload response level.
public OverloadLevel CurrentOverloadLevel { get; }
Property Value
CurrentTickNumber
Number of ticks executed so far.
public long CurrentTickNumber { get; }
Property Value
Engine
The underlying database engine.
public DatabaseEngine Engine { get; }
Property Value
Options
The runtime options this runtime was created with. The profiler derives session metadata from these.
public RuntimeOptions Options { get; }
Property Value
PublishedViews
The published View registry (for diagnostics and testing).
public PublishedViewRegistry PublishedViews { get; }
Property Value
Scheduler
The DAG scheduler driving tick execution.
public DagScheduler Scheduler { get; }
Property Value
Systems
All registered systems including engine-internal ones (e.g. FenceExec). Use this when you need the full system list, indexed by canonical system
index. For "the systems the user registered" use UserSystems instead.
public SystemDefinition[] Systems { get; }
Property Value
Telemetry
Telemetry ring buffer for diagnostic inspection.
public TickTelemetryRing Telemetry { get; }
Property Value
UserSystems
User-registered systems only (filters out engine-tagged-track systems such as the Fence DAG).
public SystemDefinition[] UserSystems { get; }
Property Value
Methods
Create(DatabaseEngine, Action<RuntimeSchedule>, RuntimeOptions, IResource, ILogger, IServiceProvider)
Creates a new TyphonRuntime from a DatabaseEngine and a schedule configuration.
public static TyphonRuntime Create(DatabaseEngine engine, Action<RuntimeSchedule> configure, RuntimeOptions options = null, IResource parent = null, ILogger logger = null, IServiceProvider serviceProvider = null)
Parameters
engineDatabaseEngineThe database engine for entity storage.
configureAction<RuntimeSchedule>Action to register systems on the RuntimeSchedule.
optionsRuntimeOptionsRuntime options. If null, defaults are used.
parentIResourceParent resource node. If null, uses the registry's Runtime node.
loggerILoggerOptional logger.
serviceProviderIServiceProviderOptional DI container. When supplied, a profiler-launch override registered via
AddTyphonProfileris resolved from it. The zero-host-code profiler path works without it — pass it only when a host wants to override config in code.
Returns
CreateSideTransaction(DurabilityMode, DurabilityDiscipline)
Creates a side-transaction with the specified durability mode. The caller owns the returned Transaction and must Commit + Dispose it. Side-transactions are NOT visible to the current tick's main Transactions (snapshot isolation).
public Transaction CreateSideTransaction(DurabilityMode durability = DurabilityMode.Immediate, DurabilityDiscipline discipline = DurabilityDiscipline.TickFence)
Parameters
durabilityDurabilityModedisciplineDurabilityDiscipline
Returns
Dispose()
public void Dispose()
PublishView(string, Func<ClientContext, ViewBase>, SubscriptionPriority)
Publish a per-client View factory. A new View is created per subscriber, parameterized by ClientContext.
public PublishedView PublishView(string name, Func<ClientContext, ViewBase> factory, SubscriptionPriority priority = SubscriptionPriority.Normal)
Parameters
namestringHuman-readable name clients use to identify this subscription.
factoryFunc<ClientContext, ViewBase>Factory that creates a View for each subscribing client.
prioritySubscriptionPrioritySubscription priority for overload throttling.
Returns
- PublishedView
The published View handle.
PublishView(string, ViewBase, SubscriptionPriority)
Publish a shared View for client subscriptions. All subscribers see the same data; the delta is serialized once and memcpy'd.
public PublishedView PublishView(string name, ViewBase view, SubscriptionPriority priority = SubscriptionPriority.Normal)
Parameters
namestringHuman-readable name clients use to identify this subscription.
viewViewBaseA dedicated ViewBase instance for subscriptions.
prioritySubscriptionPrioritySubscription priority for overload throttling.
Returns
- PublishedView
The published View handle.
Remarks
The View must be a dedicated instance — it must NOT be used as a system input. Published Views are refreshed only during the Output phase; using the same View as system input would consume ring buffer entries needed by subscriptions.
RegisterContext<TContext>(TContext)
Bind an ambient context onto every registered system deriving from ChunkedCallbackSystem<TContext>. Must be called after Configure (systems must already be registered) and before Start().
public void RegisterContext<TContext>(TContext context) where TContext : class
Parameters
contextTContext
Type Parameters
TContext
SetSubscriptions(ClientContext, params PublishedView[])
Set a client's subscription set. Replaces the previous set atomically. The transition is applied during the next tick's Output phase. Looks up the connection by ConnectionId — the public client identity. If the connection has been dropped between the caller obtaining the context and this call, the request is silently ignored (the next tick will see no pending change for a disposed client anyway).
public void SetSubscriptions(ClientContext client, params PublishedView[] views)
Parameters
clientClientContextviewsPublishedView[]
Remarks
If called multiple times within a tick, the last call wins.
Shutdown()
Gracefully shuts down the runtime. Stops the subscription server, fires OnShutdown, then stops the scheduler.
public void Shutdown()
Start()
Starts the scheduler (worker threads + tick driver) and the subscription server (if configured).
public void Start()
Events
OnCriticalOverload
Fires when overload reaches PlayerShedding. Game code decides what to do (migrate, disconnect, split).
public event Action<TyphonRuntime> OnCriticalOverload
Event Type
OnFirstTick
Fired once on the first tick. Use to rebuild transient state after crash recovery. The callback receives a valid Transaction for entity operations.
public event Action<TickContext> OnFirstTick
Event Type
OnShutdown
Fired during Shutdown(). Use for cleanup (save player state, etc.). The callback receives a dedicated Transaction (Immediate durability).
public event Action<TickContext> OnShutdown