AS AgentScopeAPI 手册 / API Reference

SandboxLockStrategy

public interface SandboxLockStrategy
源码Source io/agentscope/extensions/jdbc/dialect/SandboxLockStrategy.java:33–44

定义沙箱锁 Strategy契约的接口。位于 io.agentscope.extensions.jdbc.dialect 包。核心成员包括 tryEnter。

Distributed lock contract implemented by AbstractJdbcDialect.

The default implementation in AbstractJdbcDialect#tryEnter uses a portable table-based lock (INSERT/DELETE with polling). Vendor dialects with native advisory locks override tryEnter — e.g. MysqlDialect uses GET_LOCK and PostgresDialect uses pg_try_advisory_lock.

Adding a new database with native lock support requires only overriding tryEnter() in the vendor dialect class — no separate strategy class needed.

方法摘要Method Summary

方法Method说明Description
public SandboxLease tryEnter(String lockName, int timeoutSeconds) throws InterruptedException
执行 `tryEnter` 方法。
Acquires the named lock, blocking until available or timeout expires.

方法详情Method Detail

tryEnter

public SandboxLease tryEnter(String lockName, int timeoutSeconds) throws InterruptedException

执行 tryEnter 方法。

Acquires the named lock, blocking until available or timeout expires.

参数Parameters
名称Name类型Type说明Description
lockNameString锁名称(类型 `String`)。a unique, validated lock name
timeoutSecondsint超时秒(类型 `int`)。maximum wait in seconds
返回Returns SandboxLease
返回SandboxLease。a lease that releases the lock when closed
抛出Throws
  • InterruptedException 可能抛出 `InterruptedException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/extensions/jdbc/dialect/SandboxLockStrategy.java:43
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.