InterruptControl
public final class InterruptControl
源码Source
io/agentscope/core/interruption/InterruptControl.java:23–74中断 Control,为框架提供通用类型与基础能力。位于 io.agentscope.core.interruption 包。核心成员包括 trigger、isInterrupted、getSource、getUserMessage、reset、toContext。
A runtime-only cooperative interrupt signal owned by one execution, never by a session.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void trigger(InterruptSource src, Msg msg) | 执行 `trigger` 方法。 Raise the interrupt signal. |
public boolean isInterrupted() | 判断是否 `isInterrupted`。 Returns whether the interrupted. |
public InterruptSource getSource() | 获取来源。 Returns the source. |
public Msg getUserMessage() | 获取用户消息。 Returns the user message. |
public void reset() | 清空或重置内部状态。 Clear the interrupt signal back to its initial (non-interrupted) state. |
public InterruptContext toContext() | 返回到上下文。 Build an `InterruptContext` snapshot of the current signal. |
方法详情Method Detail
trigger
public void trigger(InterruptSource src, Msg msg)
执行 trigger 方法。
Raise the interrupt signal.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
src | InterruptSource | src(类型 `InterruptSource`)。the interrupt source; `null` is treated as `InterruptSource#USER` |
msg | Msg | 消息(类型 `Msg`)。an optional user message associated with the interruption (ignored when ` null`) |
源码Source
io/agentscope/core/interruption/InterruptControl.java:37–43isInterrupted
public boolean isInterrupted()
判断是否 isInterrupted。
Returns whether the interrupted.
boolean返回布尔值,表示判断结果。`true` if this execution has been interrupted and not yet reset
源码Source
io/agentscope/core/interruption/InterruptControl.java:46–48getSource
public InterruptSource getSource()
获取来源。
Returns the source.
InterruptSource当前中断来源。the current interrupt source
源码Source
io/agentscope/core/interruption/InterruptControl.java:51–53getUserMessage
public Msg getUserMessage()
获取用户消息。
Returns the user message.
Msg返回消息。the user message associated with the interruption, or `null`
源码Source
io/agentscope/core/interruption/InterruptControl.java:56–58reset
public void reset()
清空或重置内部状态。
Clear the interrupt signal back to its initial (non-interrupted) state.
源码Source
io/agentscope/core/interruption/InterruptControl.java:61–65toContext
public InterruptContext toContext()
返回到上下文。
Build an InterruptContext snapshot of the current signal.
InterruptContext返回InterruptContext。Returns interrupt context.
源码Source
io/agentscope/core/interruption/InterruptControl.java:68–73