Table of Contents

Struct CommandBatch<T>

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

This tick's commands of one type, in per-session arrival order.

public readonly struct CommandBatch<T> where T : unmanaged

Type Parameters

T

The command's struct.

Inherited Members

Remarks

Order within a session is the contract; order between sessions is not. A session is drained by exactly one worker, which appends its records to that worker's own segment in arrival order, so walking the segments preserves each client's order without preserving any order between clients — which nothing needs (SUB-08, foundation/05 § 4.2).

Nothing here allocates. The batch is a view over the drain's buffers; the enumerator is a struct whose Current is a reference to its own field, refreshed per step, so foreach (ref readonly var c in …) costs one copy of the command and no heap traffic at all.

Properties

Count

How many commands this batch carries.

public int Count { get; }

Property Value

int

Methods

ForSession(SessionId)

Narrows the batch to one session's commands, in the order it sent them.

public CommandBatch<T> ForSession(SessionId session)

Parameters

session SessionId

The session.

Returns

CommandBatch<T>

The narrowed batch, empty when that session sent none this tick.

Remarks

O(1), and it is what lets a parallel system apply each client's commands on the worker that already owns that client's entities, instead of one system walking the whole tick's batch (01-model § 7).

GetEnumerator()

Walks the batch.

public CommandBatch<T>.Enumerator GetEnumerator()

Returns

CommandBatch<T>.Enumerator

The enumerator.

TryGetLatest(SessionId, out ClientCommand<T>)

The newest command this session sent this tick, for a type declared LatestPerSession.

public bool TryGetLatest(SessionId session, out ClientCommand<T> command)

Parameters

session SessionId

The session.

command ClientCommand<T>

The command.

Returns

bool

false when that session sent none this tick.

Remarks

O(1): the drain overwrites the session's single record in place rather than appending, and keeps the index of it. That is also why a coalesced type's batch carries exactly one record per session — the older ones never existed as records at all.