feat(battlenode): per-session charaId + single-active-engine gate (Phase 2 N2 carried-risk B)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
17
SVSim.BattleNode/Sessions/Engine/EngineSessionGate.cs
Normal file
17
SVSim.BattleNode/Sessions/Engine/EngineSessionGate.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace SVSim.BattleNode.Sessions.Engine;
|
||||
|
||||
/// <summary>Process-wide single-active-engine gate. The engine's process-global turn state
|
||||
/// (ToolboxGame.RealTimeNetworkAgent, GameMgr) cannot safely back two concurrent battles, so exactly
|
||||
/// one BattleSession may own the engine at a time (AskUserQuestion 2026-06-06: serialize + document).
|
||||
/// A session that cannot acquire runs WITHOUT the engine and logs it loudly — NOT a silent fallback
|
||||
/// (the operator sees the limitation). Per-session isolation (removing this gate) is the tracked
|
||||
/// follow-up. Non-blocking TryAcquire keeps it out of the synchronous dispatch path; in local
|
||||
/// single-user dev battles are sequential, so contention never arises.</summary>
|
||||
internal static class EngineSessionGate
|
||||
{
|
||||
private static int _owned; // 0 = free, 1 = owned
|
||||
|
||||
public static bool TryAcquire() => System.Threading.Interlocked.CompareExchange(ref _owned, 1, 0) == 0;
|
||||
|
||||
public static void Release() => System.Threading.Interlocked.Exchange(ref _owned, 0);
|
||||
}
|
||||
Reference in New Issue
Block a user