MemoryBackgroundTasks
public final class MemoryBackgroundTasks
io/agentscope/harness/agent/memory/MemoryBackgroundTasks.java:33–88记忆 Background 任务,在多次调用之间保存和恢复会话与记忆数据。位于 io.agentscope.harness.agent.memory 包。核心成员包括 begin、end、awaitQuiescence。
Tracks in-flight fire-and-forget memory background tasks (flush, maintenance) so
HarnessAgent.close() can wait for them to quiesce before releasing resources.
The middleware instances that dispatch these tasks are created per agent call, so they
cannot be reached from the agent's close() method. Like
io.agentscope.harness.agent.memory.session.SessionTree#awaitMirrorQuiescence, the
in-flight count is process-wide: close() blocks until every background task started
before the call has finished, so async workspace writes do not race with resource cleanup
(e.g. temp workspace deletion in tests).
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static void begin()static | 执行 `begin` 方法。 Marks the start of a fire-and-forget background task. |
public static void end()static | 执行结束相关操作。 Marks the end of a fire-and-forget background task (must pair with `#begin()`). |
public static boolean awaitQuiescence(long timeout, TimeUnit unit)static | 执行 `awaitQuiescence` 方法。 Blocks until all background tasks started before this call have finished, or the timeout
elapses. |
方法详情Method Detail
begin
public static void begin()
执行 begin 方法。
Marks the start of a fire-and-forget background task.
io/agentscope/harness/agent/memory/MemoryBackgroundTasks.java:43–47end
public static void end()
执行结束相关操作。
Marks the end of a fire-and-forget background task (must pair with #begin()).
io/agentscope/harness/agent/memory/MemoryBackgroundTasks.java:50–59awaitQuiescence
public static boolean awaitQuiescence(long timeout, TimeUnit unit)
执行 awaitQuiescence 方法。
Blocks until all background tasks started before this call have finished, or the timeout elapses.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
timeout | long | 超时时间(类型 `long`)。maximum time to wait |
unit | TimeUnit | unit(类型 `TimeUnit`)。time unit of `timeout` |
booleanio/agentscope/harness/agent/memory/MemoryBackgroundTasks.java:69–87