Table of Contents

Class PointInTimeAccessor

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Thread-safe, lightweight snapshot accessor for parallel entity access. Constructed once (empty), then Attach(DatabaseEngine, int)ed before each parallel system dispatch to obtain a fresh TSN. Per-worker EntityAccessor instances are stored in a flat array indexed by worker ID — zero per-entity dictionary overhead.

Supports reading all storage modes (Versioned via MVCC chain walk, SingleVersion/Transient direct). Supports writing SingleVersion and Transient components. Throws on Versioned writes. Does not support Spawn, Destroy, Commit, or Rollback.

Reuse pattern: A single PTA is constructed once and reused across all non-Versioned parallel systems within a tick and across ticks. Call Attach(DatabaseEngine, int) before each system dispatch — it allocates a fresh TSN and resets per-worker EntityAccessors while preserving ChunkAccessor page caches (zero allocation after first-tick warmup).

public sealed class PointInTimeAccessor : IDisposable
Inheritance
PointInTimeAccessor
Implements
Inherited Members

Constructors

PointInTimeAccessor()

Creates an empty PointInTimeAccessor. Call Attach(DatabaseEngine, int) before use.

public PointInTimeAccessor()

Properties

IsAttached

Whether this accessor has been attached to a DatabaseEngine and has a valid TSN.

public bool IsAttached { get; }

Property Value

bool

TSN

The frozen MVCC snapshot timestamp. All workers see the same snapshot.

public long TSN { get; }

Property Value

long

Methods

AdvanceSnapshot()

Advance to a new MVCC snapshot. Equivalent to Attach(DatabaseEngine, int) but reuses the existing engine and worker count.

public void AdvanceSnapshot()

Attach(DatabaseEngine, int)

Attach (or re-attach) this accessor with a fresh TSN. On first call: stores the engine reference and worker count, allocates the accessor array and a TSN. On subsequent calls: allocates a fresh TSN and resets all existing per-worker EntityAccessors via Typhon.Engine.EntityAccessor.ResetForNewSnapshot(System.Int64), preserving ChunkAccessor page caches.

Must be called from a single thread (the prepare phase), NOT concurrently with worker access.

public void Attach(DatabaseEngine dbe, int workerCount)

Parameters

dbe DatabaseEngine
workerCount int

Create(DatabaseEngine, int)

Creates a PointInTimeAccessor with a frozen MVCC snapshot at the current TSN.

public static PointInTimeAccessor Create(DatabaseEngine dbe, int workerCount = 1)

Parameters

dbe DatabaseEngine
workerCount int

Returns

PointInTimeAccessor

Dispose()

Detaches this accessor and disposes every per-worker EntityAccessor it owns; idempotent.

public void Dispose()

FlushWorker(int)

Flush the given worker's EntityAccessor and refresh its epoch scope. Called at the end of each parallel chunk callback on the worker thread.

public void FlushWorker(int workerId)

Parameters

workerId int

GetWorkerAccessor(int)

Get or create the EntityAccessor for the given worker. Called ONCE per chunk at chunk start. The returned accessor is used directly for all Open/OpenMut calls — zero per-entity overhead.

public EntityAccessor GetWorkerAccessor(int workerId)

Parameters

workerId int

Returns

EntityAccessor