Skip to main content

Module engine

Module engine 

Source
Expand description

The engine: a lifecycle, a state machine, and a table of what is running.

§What this owns

A Session and a RequestRegistry, plus the negotiated Resolution a Lifecycle produced. Everything protocol-specific is a call into the lifecycle; the two associated types are stored opaquely and handed back whenever a judgement is needed. Nothing here names ProtocolVersion, FeatureProfile, or a method of any protocol.

§Single-writer, and why that is a decision

Every method here takes &mut self. The engine is single-writer on purpose: the session’s phase, the negotiated profile, and the in-flight table have to move together, and a lock would let two of them move separately. A transport that reads frames on one task and runs handlers on others puts the engine behind a Mutex and calls the &mut methods between polls — which is why dispatch hands the handler its own CancellationToken before it awaits, so a canceller never needs the engine to stay unlocked across the wait.

What the engine refuses to be is a Send-and-Sync bag of locks. The concurrency belongs to the adapter that knows how many tasks it has.

Structs§

SessionEngine
A session, its protocol, and everything in flight on it.

Enums§

Dispatch
What a handler produced, and what happened to it.
EngineError
Why a session could not do what was asked.
Refusal
A message the session would not admit, and why.