Class GraalJsEventConcurrencyTest

java.lang.Object
scripting.GraalJsEventConcurrencyTest

public class GraalJsEventConcurrencyTest extends Object
Track B — C0 SPIKE 事件執行緒序列化 gate(R8/R9/R10/R13)。

GraalJS Context 禁止並發,但事件引擎被 Netty packet 執行緒 + EventTimer 多執行緒 共用同一 Invocable。本測試:

  1. 修前必 FAIL:未序列化時兩執行緒重疊進入同一 GraalJS 引擎 → 拋 IllegalStateException("Multi threaded access ... not allowed for language(s) js")。
  2. 修後必 PASS:經 ScriptEngines.serialized(Invocable)(per-engine ReentrantLock)→ 無例外、inFlight 永不 >1、跨呼叫狀態保留(證持久 context, 非 per-invocation 隔離)。
  3. per-event 粒度:兩個不同引擎(兩鎖)並發 → 牆鐘 ≈ max 非 sum(不是全域序列化)。
  4. NPC 序列回歸:同一 GraalJS 引擎換執行緒「不重疊」進入合法,毋須額外鎖(規則 b)。
  • Constructor Details

    • GraalJsEventConcurrencyTest

      public GraalJsEventConcurrencyTest()
  • Method Details

    • concurrentEntryWithoutSerializationThrows

      public void concurrentEntryWithoutSerializationThrows() throws Exception
      Throws:
      Exception
    • serializedPreventsConcurrencyAndPreservesState

      public void serializedPreventsConcurrencyAndPreservesState() throws Exception
      Throws:
      Exception
    • perEventGranularityTwoEnginesOverlap

      public void perEventGranularityTwoEnginesOverlap() throws Exception
      Throws:
      Exception
    • npcSequentialThreadChangeIsLegal

      public void npcSequentialThreadChangeIsLegal() throws Exception
      Throws:
      Exception