Table of Contents

Class ServiceCollectionExtensions

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Dependency-injection registration for the Typhon engine and its subsystems. AddTyphon(IServiceCollection, Action<TyphonOptions>) is the one-line entry point most hosts want — it composes the whole service graph and leaves a ready-to-use DatabaseEngine. The individual Add* methods, each offered in Singleton / Scoped / Transient lifetime variants, compose that graph piece by piece for callers who need finer control over lifetimes or want to substitute a subsystem.

public static class ServiceCollectionExtensions
Inheritance
ServiceCollectionExtensions
Inherited Members

Methods

AddDatabaseEngine(IServiceCollection, Action<DatabaseEngineOptions>)

Registers the top-level DatabaseEngine — Typhon's ACID/ECS engine — as a singleton, configured via configure. This is the power-user path: unlike AddTyphon(IServiceCollection, Action<TyphonOptions>), the caller owns component/archetype registration and must call InitializeArchetypes() before the engine is used.

public static IServiceCollection AddDatabaseEngine(this IServiceCollection services, Action<DatabaseEngineOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<DatabaseEngineOptions>

Optional configuration of DatabaseEngineOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddDeadlineWatchdog(IServiceCollection)

Registers the singleton Typhon.Engine.Internals.DeadlineWatchdog — enforces per-operation deadlines by watching the shared timer and tripping work that overruns. Depends on IResourceRegistry and Typhon.Engine.Internals.HighResolutionSharedTimerService.

public static IServiceCollection AddDeadlineWatchdog(this IServiceCollection services)

Parameters

services IServiceCollection

The service collection to add to.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddEpochManager(IServiceCollection)

Registers the singleton Typhon.Engine.Internals.EpochManager — the epoch-based reclamation coordinator that keeps a memory page alive while any reader still holds a raw pointer into it, so eviction or reuse can never pull memory out from under an in-flight read. Depends on IResourceRegistry.

public static IServiceCollection AddEpochManager(this IServiceCollection services)

Parameters

services IServiceCollection

The service collection to add to.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddHighResolutionSharedTimer(IServiceCollection)

Registers the singleton Typhon.Engine.Internals.HighResolutionSharedTimerService — one shared high-resolution timer that the deadline/timeout machinery drives, rather than each component running its own. Depends on IResourceRegistry.

public static IServiceCollection AddHighResolutionSharedTimer(this IServiceCollection services)

Parameters

services IServiceCollection

The service collection to add to.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddManagedPagedMMF(IServiceCollection, Action<ManagedPagedMMFOptions>)

Registers Typhon.Engine.Internals.ManagedPagedMMF — the segment-aware store the engine builds on, layering logical segments, occupancy tracking, and epoch integration over Typhon.Engine.Internals.PagedMMF — as a singleton, configured via configure.

public static IServiceCollection AddManagedPagedMMF(this IServiceCollection services, Action<ManagedPagedMMFOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<ManagedPagedMMFOptions>

Optional configuration of Typhon.Engine.Internals.ManagedPagedMMFOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddMemoryAllocator(IServiceCollection, Action<MemoryAllocatorOptions>)

Registers the engine's pinned-memory provider — Typhon.Engine.Internals.IMemoryAllocator, backed by Typhon.Engine.Internals.MemoryAllocator — as a singleton. Supplies GC-stable memory blocks to every other subsystem; depends on IResourceRegistry.

public static IServiceCollection AddMemoryAllocator(this IServiceCollection services, Action<MemoryAllocatorOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<MemoryAllocatorOptions>

Optional configuration of Typhon.Engine.Internals.MemoryAllocatorOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddPagedMemoryMappedFile(IServiceCollection, Action<PagedMMFOptions>)

Registers Typhon.Engine.Internals.PagedMMF — the low-level paged memory-mapped file store (raw pages, page cache, checkpoint) — as a singleton, configured via configure. Most callers want AddManagedPagedMMF(IServiceCollection, Action<ManagedPagedMMFOptions>) or AddTyphon(IServiceCollection, Action<TyphonOptions>) instead.

public static IServiceCollection AddPagedMemoryMappedFile(this IServiceCollection services, Action<PagedMMFOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<PagedMMFOptions>

Optional configuration of PagedMMFOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddResourceRegistry(IServiceCollection, Action<ResourceRegistryOptions>)

Registers IResourceRegistry — backed by ResourceRegistry — as a singleton. The registry owns the engine's shared runtime resources (timer wheel, synchronization, storage bookkeeping) that the allocator, timers, epoch manager, and storage all draw on.

public static IServiceCollection AddResourceRegistry(this IServiceCollection services, Action<ResourceRegistryOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<ResourceRegistryOptions>

Optional configuration of ResourceRegistryOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddScopedDatabaseEngine(IServiceCollection, Action<DatabaseEngineOptions>)

public static IServiceCollection AddScopedDatabaseEngine(this IServiceCollection services, Action<DatabaseEngineOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<DatabaseEngineOptions>

Optional configuration of DatabaseEngineOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddScopedEpochManager(IServiceCollection)

Scoped-lifetime variant of AddEpochManager(IServiceCollection).

public static IServiceCollection AddScopedEpochManager(this IServiceCollection services)

Parameters

services IServiceCollection

The service collection to add to.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddScopedManagedPagedMemoryMappedFile(IServiceCollection, Action<ManagedPagedMMFOptions>)

public static IServiceCollection AddScopedManagedPagedMemoryMappedFile(this IServiceCollection services, Action<ManagedPagedMMFOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<ManagedPagedMMFOptions>

Optional configuration of Typhon.Engine.Internals.ManagedPagedMMFOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddScopedMemoryAllocator(IServiceCollection, Action<MemoryAllocatorOptions>)

public static IServiceCollection AddScopedMemoryAllocator(this IServiceCollection services, Action<MemoryAllocatorOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<MemoryAllocatorOptions>

Optional configuration of Typhon.Engine.Internals.MemoryAllocatorOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddScopedPagedMemoryMappedFile(IServiceCollection, Action<PagedMMFOptions>)

public static IServiceCollection AddScopedPagedMemoryMappedFile(this IServiceCollection services, Action<PagedMMFOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<PagedMMFOptions>

Optional configuration of PagedMMFOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddScopedResourceRegistry(IServiceCollection, Action<ResourceRegistryOptions>)

public static IServiceCollection AddScopedResourceRegistry(this IServiceCollection services, Action<ResourceRegistryOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<ResourceRegistryOptions>

Optional configuration of ResourceRegistryOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddTransientDatabaseEngine(IServiceCollection, Action<DatabaseEngineOptions>)

public static IServiceCollection AddTransientDatabaseEngine(this IServiceCollection services, Action<DatabaseEngineOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<DatabaseEngineOptions>

Optional configuration of DatabaseEngineOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddTransientEpochManager(IServiceCollection)

Transient-lifetime variant of AddEpochManager(IServiceCollection).

public static IServiceCollection AddTransientEpochManager(this IServiceCollection services)

Parameters

services IServiceCollection

The service collection to add to.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddTransientManagedPagedMemoryMappedFile(IServiceCollection, Action<ManagedPagedMMFOptions>)

public static IServiceCollection AddTransientManagedPagedMemoryMappedFile(this IServiceCollection services, Action<ManagedPagedMMFOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<ManagedPagedMMFOptions>

Optional configuration of Typhon.Engine.Internals.ManagedPagedMMFOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddTransientMemoryAllocator(IServiceCollection, Action<MemoryAllocatorOptions>)

public static IServiceCollection AddTransientMemoryAllocator(this IServiceCollection services, Action<MemoryAllocatorOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<MemoryAllocatorOptions>

Optional configuration of Typhon.Engine.Internals.MemoryAllocatorOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddTransientPagedMemoryMappedFile(IServiceCollection, Action<PagedMMFOptions>)

public static IServiceCollection AddTransientPagedMemoryMappedFile(this IServiceCollection services, Action<PagedMMFOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<PagedMMFOptions>

Optional configuration of PagedMMFOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddTransientResourceRegistry(IServiceCollection, Action<ResourceRegistryOptions>)

public static IServiceCollection AddTransientResourceRegistry(this IServiceCollection services, Action<ResourceRegistryOptions> configure = null)

Parameters

services IServiceCollection

The service collection to add to.

configure Action<ResourceRegistryOptions>

Optional configuration of ResourceRegistryOptions. May be null to accept the defaults.

Returns

IServiceCollection

The same IServiceCollection, for chaining.

AddTyphon(IServiceCollection, Action<TyphonOptions>)

One-line Typhon setup: composes the full engine service graph (memory allocator, resource registry, timers, epoch manager, storage, engine) and, at first resolve, applies the configured component + archetype registrations and runs InitializeArchetypes — so the resolved DatabaseEngine is ready to use. All from a single TyphonOptions fluent block. The individual Add* methods remain available for power users who need finer control (they own InitializeArchetypes themselves).

public static IServiceCollection AddTyphon(this IServiceCollection services, Action<TyphonOptions> configure)

Parameters

services IServiceCollection
configure Action<TyphonOptions>

Returns

IServiceCollection

Examples

services.AddTyphon(o => o.DatabaseFile("game.typhon").Register<Position>()); // archetypes self-register at assembly load (#514)

AddTyphonProfiler(IServiceCollection, Func<ProfilerLaunchConfig, ProfilerLaunchConfig>)

Register a host-supplied profiler-launch override.

public static IServiceCollection AddTyphonProfiler(this IServiceCollection services, Func<ProfilerLaunchConfig, ProfilerLaunchConfig> configure = null)

Parameters

services IServiceCollection
configure Func<ProfilerLaunchConfig, ProfilerLaunchConfig>

Returns

IServiceCollection

Remarks

The runtime self-wires the profiler from typhon.telemetry.json by default — a host needs zero code to get profiling. Call this only to adjust the resolved ProfilerLaunchConfig in code (e.g. to layer CLI args on top, or compute a trace path at runtime). configure receives the config resolved from file + environment and returns the effective config; precedence is JSON file → environment → this delegate. For the override to be seen, the host must pass its IServiceProvider to Create(DatabaseEngine, Action<RuntimeSchedule>, RuntimeOptions, IResource, ILogger, IServiceProvider).

EnsureFileDeleted<TO>(IServiceProvider)

Resolves the TO storage options from provider and deletes the entire database bundle they point at (data file, lock, and WAL). Intended for tests and tooling that reset a database between runs; the database must be closed first — see EnsureFileDeleted().

public static void EnsureFileDeleted<TO>(this IServiceProvider provider) where TO : PagedMMFOptions

Parameters

provider IServiceProvider

The service provider to resolve the options from; a scope is created internally.

Type Parameters

TO

The storage options type (a PagedMMFOptions subtype) whose bundle location is deleted.