Class LocalSessionTurnGate
java.lang.Object
io.agentscope.harness.agent.gateway.LocalSessionTurnGate
- All Implemented Interfaces:
SessionTurnGate
Process-local fair per-key mutual exclusion for gateway turns.
Uses a fair Semaphore per key. acquire(String) blocks until the slot is
available; it never throws TurnBusyException.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
LocalSessionTurnGate
public LocalSessionTurnGate()
-
-
Method Details
-
acquire
Description copied from interface:SessionTurnGateAcquires the turn slot for the given key, blocking until available or throwing when busy.- Specified by:
acquirein interfaceSessionTurnGate- Parameters:
key- canonical gate key (typicallyMsgContext.canonicalKey())- Returns:
- a lease that must be closed to release the slot
- Throws:
InterruptedException- if the waiting thread is interrupted
-
isRunning
Description copied from interface:SessionTurnGateNon-blocking check: returnstruewhen a turn is currently held for the given key. Used byWakeupDispatcherto skip sessions that are already active.- Specified by:
isRunningin interfaceSessionTurnGate- Parameters:
key- canonical gate key- Returns:
truewhen a turn is in progress for the key
-